Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / May 2006

Tip: Looking for answers? Try searching our database.

DataGridView with different ComboBox items in each row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jens.ro - 06 Apr 2006 18:58 GMT
I have a DataGridView with three columns. The first two columns contain
ComboBoxes, the third column contains textboxes. The ComboBoxes of the
first column always have the same list of items, but in the second
column, the items depend on the selection of the cell in the first
column (so for each row there can be different items in the ComboBox of
the second column).

How can I realize this? How can the data source for the
DataGridViewComboBoxColumn control what items to deliver (i.e. how can
the data source know which row is the one that will be provided with
data)?

Regards, Jens
jens.ro - 08 Apr 2006 10:55 GMT
I thought about the following solution:

I create an event handler for the CellEnter event. When the event
occurs for a cell of the second column, I check the value of the cell
in the first column and set the data source for the second column
accordingly.

Any comments to this solution? Is there a better one?

Jens
jens.ro - 08 Apr 2006 14:40 GMT
I've found a better solution on my own:

I found out that each cell in the column can have its own data source.
So what I'm now doing is reacting on the CellValueChanged event for the
first column. Inside the event handler I check the value of the cell in
the first column and set the data source of the cell in the second
column accordingly. Additionally I reset the value of the cell in the
second column to a default value to fit to the new data source.

This works fine except one problem I have:
The cell in the second column is only updated when I move the focus to
another cell. What can I do to have the cell updated immediately?

Jens
Fran Garcia - 19 May 2006 10:40 GMT
Jens,

I have exactly the same problem. Moreover, I don't want to fill the combo
box until it is going to drop down. I don't want to access database many
times just to fill combo boxes that might never be opened (or whose data
might change before they are dropped down).

Did you come up with a solution?

Thanks in advance,

   Francisco Garcia

>I have a DataGridView with three columns. The first two columns contain
> ComboBoxes, the third column contains textboxes. The ComboBoxes of the
[quoted text clipped - 9 lines]
>
> Regards, Jens
jens.ro - 24 May 2006 19:18 GMT
Unfortunately, my above solution is not perfect. When the user adds a
new row, I get a cell error event. Up to now I don't have a solution
for that. Also the problem with the not updating cell content is not
yet solved. I will post as soon as I have a solution.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.