|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
C#, WinForms, DataGridViewComboBoxColumnI'm using a datagridview that's populate from a products table.
In the grid, I need to have combo box column, that's populated from a different table, but needs to be selected from the rows in the products table. Anyone with sample or links that accomplishes this? I can't seem to find anything in Google about binding the combo box to the grid table. Okay, it's a little confusing, but not as hard as it might seem. The
DataGridView itself has a DataSource property that determines what columns are in it. The DataGridViewComboBox column also has a DataSource property, but that isn't the same as the DataSource of the DataGridView. It is the DataSource that is used to populate the ComboBox in each cell. The DataMember and ValueMember properties are the column names of the columns in the ComboBox's DataSource that define what is displayed in the ComboBox, and the underlying value for that item. It is the DataPropertyName property of the DataGridViewComboBoxColumn that determines the column name in the DataGridView's DataSource that the DataGridViewComboBoxColumn is associated with. The ValueMember determines the value that will be set for that column in the DataGridView's DataSource. -- Show quoteHTH, Kevin Spencer Microsoft MVP Professional Numbskull Hard work is a medication for which there is no placebo. "Richard" <Rich***@discussions.microsoft.com> wrote in message news:71E6225C-CDDC-44B5-8C4E-AD8E31FDB04C@microsoft.com... > I'm using a datagridview that's populate from a products table. > > In the grid, I need to have combo box column, that's populated from a > different table, but needs to be selected from the rows in the products > table. > > Anyone with sample or links that accomplishes this? I can't seem to find > anything in Google about binding the combo box to the grid table. Thank you!
Show quote "Kevin Spencer" wrote: > Okay, it's a little confusing, but not as hard as it might seem. The > DataGridView itself has a DataSource property that determines what columns > are in it. The DataGridViewComboBox column also has a DataSource property, > but that isn't the same as the DataSource of the DataGridView. It is the > DataSource that is used to populate the ComboBox in each cell. The > DataMember and ValueMember properties are the column names of the columns in > the ComboBox's DataSource that define what is displayed in the ComboBox, and > the underlying value for that item. It is the DataPropertyName property of > the DataGridViewComboBoxColumn that determines the column name in the > DataGridView's DataSource that the DataGridViewComboBoxColumn is associated > with. The ValueMember determines the value that will be set for that column > in the DataGridView's DataSource. > > -- > HTH, > > Kevin Spencer > Microsoft MVP > Professional Numbskull > > Hard work is a medication for which > there is no placebo. > > "Richard" <Rich***@discussions.microsoft.com> wrote in message > news:71E6225C-CDDC-44B5-8C4E-AD8E31FDB04C@microsoft.com... > > I'm using a datagridview that's populate from a products table. > > > > In the grid, I need to have combo box column, that's populated from a > > different table, but needs to be selected from the rows in the products > > table. > > > > Anyone with sample or links that accomplishes this? I can't seem to find > > anything in Google about binding the combo box to the grid table. > > > No problem. While the DataGridView is a masterwork of architecture, it is
also a monster in terms of sheer size and complexity. It took me a good while to figure out some of these things for myself! -- Show quoteHTH, Kevin Spencer Microsoft MVP Professional Numbskull Hard work is a medication for which there is no placebo. "Richard" <Rich***@discussions.microsoft.com> wrote in message news:C3DDC164-5932-4287-BF41-AF0581128137@microsoft.com... > Thank you! > > > "Kevin Spencer" wrote: > >> Okay, it's a little confusing, but not as hard as it might seem. The >> DataGridView itself has a DataSource property that determines what >> columns >> are in it. The DataGridViewComboBox column also has a DataSource >> property, >> but that isn't the same as the DataSource of the DataGridView. It is the >> DataSource that is used to populate the ComboBox in each cell. The >> DataMember and ValueMember properties are the column names of the columns >> in >> the ComboBox's DataSource that define what is displayed in the ComboBox, >> and >> the underlying value for that item. It is the DataPropertyName property >> of >> the DataGridViewComboBoxColumn that determines the column name in the >> DataGridView's DataSource that the DataGridViewComboBoxColumn is >> associated >> with. The ValueMember determines the value that will be set for that >> column >> in the DataGridView's DataSource. >> >> -- >> HTH, >> >> Kevin Spencer >> Microsoft MVP >> Professional Numbskull >> >> Hard work is a medication for which >> there is no placebo. >> >> "Richard" <Rich***@discussions.microsoft.com> wrote in message >> news:71E6225C-CDDC-44B5-8C4E-AD8E31FDB04C@microsoft.com... >> > I'm using a datagridview that's populate from a products table. >> > >> > In the grid, I need to have combo box column, that's populated from a >> > different table, but needs to be selected from the rows in the products >> > table. >> > >> > Anyone with sample or links that accomplishes this? I can't seem to >> > find >> > anything in Google about binding the combo box to the grid table. >> >> >> |
|||||||||||||||||||||||