TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Udi Goldstein
NA
22
63.7k
Combobox in DataGridView
Aug 27 2010 4:36 PM
Hi,
I'm trying to setup a DataGridView with ComboBox, but I can't manage to setup the selected value of the combobox.
The ComboBox value & display members are from table[1] of a Dataset object, and the rest of the datagrid columns are from Table[0] of the dataset. "noseID" (the primary key in Table[1] and the foreign key in Table[0]). How do I apply a selected value for the combobox? Here's my code:
private void SetupDataGridView() { this.Controls.Add(afikimGrid); DataGridViewComboBoxColumn comboGrid = new DataGridViewComboBoxColumn(); comboGrid.DataSource = dsRisk.Tables[1]; comboGrid.DisplayMember = "NoseDesc"; comboGrid.ValueMember = "NoseID"; afikimGrid.DataSource = dsRisk.Tables[0]; afikimGrid.Columns.Add(comboGrid); }
{
this.Controls.Add(afikimGrid);
DataGridViewComboBoxColumn comboGrid = new DataGridViewComboBoxColumn();
comboGrid.DataSource = dsRisk.Tables[1];
comboGrid.DisplayMember = "NoseDesc";
comboGrid.ValueMember = "NoseID";
afikimGrid.DataSource = dsRisk.Tables[0];
afikimGrid.Columns.Add(comboGrid);
}
Thanks,
Udi
Reply
Answers (
1
)
Filewatcher with email alert
Free IDE?