Solved

selecting un-used items only

Posted on 2012-04-12
4
217 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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
export data table to excel in vb.net 10 36
Loops and updating in SQL Query 9 54
Convert Ctime to date time in textfile? 7 32
Access/Visual Basic Question 3 25
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

837 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