Solved

selecting un-used items only

Posted on 2012-04-12
4
218 Views
Last Modified: 2012-04-20
Hi All,

I have two datagridviews in a parent child relationship.
The child datagridview that has a combo box column bound to a dataset that fills up the column(called it column A) with values -basically it picks the value name from the master record(for example value currencyid -its master record has the currency name which user can easily identify-*thats just an example of the concept)

I want to be able to:
(1)select the parent row and in the child datagridview, have column A be filled with the correct values for each child row.
(2)when i want to add a new child row,column A only populate with records not previously used.(actualy am using a view to check if the value in A has a balance or not and i want to populate only those with balances)

The problem is that when I use a select statement that filters so as to get point (2), databinding is not possible (point 1)

How do I resolve this so that when a user starts a new child row they get only the filtered data -and not affect the earlier data which is databound?
0
Comment
Question by:NormanMaina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37839338
>The problem is that when I use a select statement that filters

Show us the code that you have tried
0
 
LVL 12

Author Comment

by:NormanMaina
ID: 37841237
CodeCruiser>I have an sql view that displays unit balances for each item...to filter i CAN just use 'where balance>0' in the table adaptor query and have it in the form load event.(this causes a problem with existing data because it is filtered out)

What I want to acheive,is only when the datagridview combobox column is expanded -to use the view and filter where balances are zero -but otherwise when loading the form to load all data.


I hope that is clearer......

The objective is to minimize on errors of wrongful entry when a user tries to save an entry that has zero balances and to make the combobox dropdown have fewer values that are current.

I could implement the same from the Save button -to validate if the unit has zero balances BUT that will not resolve having a datagridview combobox with thousands of items where you only need to select one.

What I could do in this case is filter he units being populated in the grid column by the date range they were entered......

Is there another way of doing -a more elegant way paharps?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37866885
You can try following links and see if you can piece together something

http://www.daniweb.com/software-development/csharp/threads/179417/datagridview-populate-combobox-for-each-row

http://www.vbdotnetforums.com/winforms-grids/10038-fill-datagridview-combobox-column.html


Another option would be to use a standard column instead of combobox column but change it to combobox when user wants to edit it

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.editingcontrolshowing.aspx
0
 
LVL 12

Author Closing Comment

by:NormanMaina
ID: 37874829
I like the second option much better.Thanks
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get month and date in a format 4 45
Asp.Net Session Question 2 36
Telerik RadEditor Control Save 8 16
VB.net VSTO Excel Ribbon error 4 14
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question