-2

hi there,

i have a datagrid view and it have a datagrid view combo box in it. i use the below code to load data to the datagrid view combo box.

DataGridViewComboBoxColumn comboBox = (DataGridViewComboBoxColumn)dgvAction.Rows[i].Cells[1].OwningColumn;
                    comboBox.Items.Clear();
                    comboBox.Items.AddRange(m.LoadUSEmp());

what i want is how can i display the first value in the datagridview combo box when the form load.

is there somthing like comboboc.selectedindex = 0 or something
i tried i but there is no method in it.

thanxxxxxxxxx

4
Contributors
4
Replies
8
Views
6 Years
Discussion Span
Last Post by rupeshbari
4

I'm so confused about your threads regarding to DataGridView control. I think you are struggling to understand the datagridview control structure & data binding and unfortunately I am unable to answer your broken posts/threads. Please don't forget to read - http://catb.org/~esr/faqs/smart-questions.html .

Always visit MSDN. Some links from MSDN for you.

1. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx
2. http://msdn.microsoft.com/en-us/library/bxt3k60s.aspx

Votes + Comments
Excellent links and suggestions :)
5k Posts, nice
0

I'm so confused about your threads regarding to DataGridView control. I think you are struggling to understand the datagridview control structure & data binding and unfortunately I am unable to answer your broken posts/threads. Please don't forget to read - http://catb.org/~esr/faqs/smart-questions.html .

Always visit MSDN. Some links from MSDN for you.

1. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx
2. http://msdn.microsoft.com/en-us/library/bxt3k60s.aspx

i am adding data to the datagrirdview combo box as the way i have posted in the first post,
how can i select the first value to be selected in that

combobox.SelectedIndex = 0 ;

dosen't work
how can i do this???

0

The combobox column is used when adding or editing a cell to select a new value for the cell from a list for pre-defined options.
The value displayed in the cell is always the value from the database or dataset.
You can not initialise the value as this comes from the underlying database or dataset.

Edited by nick.crane: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.