Solved

selecting un-used items only

Posted on 2012-04-12
4
213 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
Comment Utility
>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
Comment Utility
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
Comment Utility
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
Comment Utility
I like the second option much better.Thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now