plz help me with datagridview question
-
Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.
-
Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.
I don't know how to do it with the MS DataGridView. But there are plenty of open sources grid views that can do that. I'd try to search in codeproject for some. I also recommend that you'll look at this: http://www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp[^] NaNg.
-
Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.
http://72.14.209.104/search?q=cache:trF3gRxXd5wJ:www.windowsforms.net/Samples/Go%2520To%2520Market/DataGridView/DataGridView%2520FAQ.doc+dataGridview+autogeneratecolumns&hl=en&ct=clnk&cd=3&gl=us[^] This always answers my questions, I suggest looking there first (I DLed the doc at the top). That said, I have never figured out your problem, I just did a work around: 1. Create an unbound DataGridViewComboBoxColumn 2. Fill it with your selectable values 3. Add it to your DataGridView 4. Set its value based on the bound column 5. Hide the bound column 6. Create a CellValueChanged event 7. On changing the unbound column value, update the bound column If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox. Good Luck Pualee -- modified at 0:30 Monday 23rd April, 2007
-
http://72.14.209.104/search?q=cache:trF3gRxXd5wJ:www.windowsforms.net/Samples/Go%2520To%2520Market/DataGridView/DataGridView%2520FAQ.doc+dataGridview+autogeneratecolumns&hl=en&ct=clnk&cd=3&gl=us[^] This always answers my questions, I suggest looking there first (I DLed the doc at the top). That said, I have never figured out your problem, I just did a work around: 1. Create an unbound DataGridViewComboBoxColumn 2. Fill it with your selectable values 3. Add it to your DataGridView 4. Set its value based on the bound column 5. Hide the bound column 6. Create a CellValueChanged event 7. On changing the unbound column value, update the bound column If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox. Good Luck Pualee -- modified at 0:30 Monday 23rd April, 2007
Pualee wrote:
If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox.
You can add the columns at design time or run time. At design time, try the "Columns" property in the IDE. You can type the column name and select type. Pualee
-
Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.
this would be the best article to explain the same http://www.codeproject.com/cs/miscctrl/RenDataGridComboBoxColumn.asp[^]
Keshav Kamat :) India