如何在SelectedIndex中将DataGridView ComboBoxColumn更改为TextBoxCell? [英] How to change DataGridView ComboBoxColumn-as TextBoxCell-in SelectedIndex ?

查看:113
本文介绍了如何在SelectedIndex中将DataGridView ComboBoxColumn更改为TextBoxCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



从以下代码,我有DataGridViewComboBox专栏... ReligionClm ...

并有一个dataRow文本添加新项目......



我的意图是,当用户选择其他行时,则没问题。但是,一旦用户选择添加新项目,则ComboBox需要将其更改为TextBoxCell ...以阅读新项目。



我尝试从ComboBox_SelectedIndex()我没有成功...我的代码任何更改都会很棒



我的代码



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

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....
}
}

推荐答案

Hi
为什么这样做你想在selectedindexchanged()中做这个吗?

你可以通过edditing dataviewgrid Template.try来做到这一点。

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


这篇关于如何在SelectedIndex中将DataGridView ComboBoxColumn更改为TextBoxCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆