Solved

selecting un-used items only

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Events in static methods 3 50
Get Count in a variable with 5 digits always 1 27
Put window Form inside tab page 10 26
Ajax Panel Not Updating When Triggered By Timer 4 40
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

18 Experts available now in Live!

Get 1:1 Help Now