Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
From the below codes, I have DataGridViewComboBox Column...ReligionClm...
and have a dataRow text "Add New Item"...

My intention is, while the user select other rows, then no problem. But, once the user
select "Add New Item" then the ComboBox need to change it as TextBoxCell...to read the new item.

I tried from ComboBox_SelectedIndex() I have not succeeded... Any changes with my code will be great

My Codes

C++
Form_Load(){
DataGridViewComboBoxColumn^ ReligionClm = gcnew DataGridViewComboBoxColumn();
this->myDataGrid1->Columns->Remove("religion");
this->myDataGrid1->Columns->Insert(5, ReligionClm);
this->myDataGrid1->Columns[5]->Name = "religion";
}

System::Void MyDataGrid1_EditingControlShowing() {
ComboBox^ ComBox = dynamic_cast<ComboBox^>(e->Control);
ComBox->SelectedIndexChanged += gcnew EventHandler(this, &Form_Form1::EmpCmb_SelectedIndexChanged);
}

System::Void EmpCmb_SelectedIndexChanged() {
if (myDataGrid1->CurrentRow->Cells["religion"]->Value=="Add New Item"){
DataGridViewTextBoxCell^ TxtBoxCell = gcnew DataGridViewTextBoxCell();
myDataGrid1[5, myDataGrid1->CurrentCell->RowIndex] = TxtBoxCell;
       ??????????? Any Chnages will be helpful....
}
}
Posted
Updated 7-Nov-13 0:32am
v2

1 solution

Hi Why do you want to do this in selectedindexchanged()?
You do thus by edditing dataviewgrid Template.try it.
Yours Farhad.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900