|
|
| |||
Loading
|
|
| |||
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
abid zaidPosted Jun 13, 2008, 1:57 AM
cl.Items.Add("One");
cl.Items.Add("Two");
cl.Items.Add("Three");
dataGridView1.Columns.Add(cl);
dataGridView1.Rows[0].Cells[0].Value ="Three";
This part indicate the row and column of your datagridviewcomboboxcolumncell
abid zaidPosted Jun 13, 2008, 1:55 AM
cl.Items.Add("One");
cl.Items.Add("Two");
cl.Items.Add("Three");
dataGridView1.Columns.Add(cl);
dataGridView1.Rows[0].Cells[1].Value ="Three";
abid zaidPosted Jun 13, 2008, 1:55 AM
cl.Items.Add("One");
cl.Items.Add("Two");
cl.Items.Add("Three");
dataGridView1.Columns.Add(cl);
dataGridView1.Rows[0].Cells[1].Value ="Three";
stephennoronhaPosted Jun 10, 2008, 9:07 AM
Hi,
Did anyone get a solution for this? I also want a default item selected in the dropdownlist. here is my code:
private void bindGrid()
{
myGridView = AddColumnsToGrid(myGridView);
-- here I want to get the default selected.... I have no idea how ---
}
private DataGridView AddColumnsToGrid(DataGridView myGridView)
{
DataGridViewComboBoxColumn m_CColumn =
new DataGridViewComboBoxColumn();
m_CColumn.DataSource = _dsDeptName.Tables[0]; <- Binding this to a datasource
m_CColumn.HeaderText = "DEPT NAME";
m_CColumn.DisplayMember = "DEPARTMENT_NAME";
m_CColumn.ValueMember = "DEPARTMENT_NAME";
myGridView.Columns.Add(m_CColumn);
return myGridView;
}
Pablo CicchinoPosted Feb 16, 2008, 8:23 AM
Niradhip ChakrabortyPosted Jan 18, 2008, 5:56 PM
abid zaidPosted Jan 10, 2008, 7:46 PM
Niradhip ChakrabortyPosted Jan 10, 2008, 5:51 PM
abid zaidPosted Jan 10, 2008, 5:29 PM
What I want is in the initialization. in other words when I add the datagridviewcombobox column,I want the first item to be selected. So that may have to deal of when adding a new row.
Niradhip ChakrabortyPosted Jan 10, 2008, 4:11 PM
Hi u can do it following way.Apply the following code in datagrid click event.
private void dataGrid1_Click(object sender, System.EventArgs e)
{
DataGridCell currentCell;
string currentCellData;
// Get the current cell.
currentCell = DataGrid1.CurrentCell;
// Get the current cell's data.
currentCellData = (string)DataGrid1[currentCell.RowNumber,currentCell.ColumnNumber];
comboBox1.Items.Clear();
comboBox1.Items.Add (currentCellData);
}