Windows Develop Bookmark and Share   
 index > Windows Forms Designer > DataGridViewComboBox Column DataBinding
 

DataGridViewComboBox Column DataBinding

Hi I have a DataGridView which is bind to a dataset.Now there is a Column named as Class. what i want i want to populate it from a different tabel which will contain all the classes. User can add a new row and select some value for class.

Now my problem is that when the form reloads again i want that the selected value should be displayed into that combo box column .

Please tell me how can i do this.

Please
Progress2007  Friday, May 15, 2009 2:40 PM

Hi,

Set the DataSource property of the DataGridViewComboBoxColumn to a data source that contains all the classes, e.g.a DataTable or a List<T>. You also need to set the ValueMember and DisplayMember properties of the combobox column.

Or, just addthe classesto the Items collection of the combobox column.

> Now my problem is that when the form reloads again i want that the selected value should be displayed into that combo box column .

If the DataGridView is data bound, set the value in the underlying data source properly; otherwise, set the Value of the combobox cell directly.

Hope this helps.

Sincerely,
Linda Liu


Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Thursday, May 21, 2009 8:45 AM

Hi,

Set the DataSource property of the DataGridViewComboBoxColumn to a data source that contains all the classes, e.g.a DataTable or a List<T>. You also need to set the ValueMember and DisplayMember properties of the combobox column.

Or, just addthe classesto the Items collection of the combobox column.

> Now my problem is that when the form reloads again i want that the selected value should be displayed into that combo box column .

If the DataGridView is data bound, set the value in the underlying data source properly; otherwise, set the Value of the combobox cell directly.

Hope this helps.

Sincerely,
Linda Liu


Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Thursday, May 21, 2009 8:45 AM

You can use google to search for other answers

Custom Search

More Threads

• VS 2003 Mouse Problem
• Text Formatting in RichText Box
• Listbox SelectedIndexChanged not firing
• " WithEvents variables cannot be typed as arrays "
• designer can't load form. Where is 'more information'?
• IDE exception an VSNET 2005 crash
• Populating the treeview with directory details
• How can I add my custom control the DataSource properties
• TypeConverter
• storing system date in MS SQL Server