如何在DataTreeListView中编辑项目时将TextBox转换为ComboBox? [英] how convert TextBox to ComboBox while editing an item in DataTreeListView?

查看:70
本文介绍了如何在DataTreeListView中编辑项目时将TextBox转换为ComboBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我有一个DataTreeListView.I想要编辑项目。在编辑单元格时应该转换为ComboBox。



当我写作

hi i have a DataTreeListView.I want to edit items. In editing on of the cells should cast to ComboBox.

when i write

private void dataTreeListView1_CellEditStarting(object sender, CellEditEventArgs e)
        {
ComboBox responsiblePersonNameCombo = (ComboBox)e.Control;

}



vs错误:

将TextBox转换为ComboBox无效!



i不知道该怎么做!


vs got error:
casting TextBox to ComboBox is invalid!

i dont know what to do!

推荐答案

将TextBox转换为ComboBox无效!

错误非常直接且不言自明。

e.Control 的数据类型为 Textbox 因此当你试图进入 Combobox ,您收到错误。
casting TextBox to ComboBox is invalid!
Error is quite straight forward and self explanatory.
e.Control is of datatype Textbox and thus when you try to cast into Combobox, you get the error.


只需尝试更改下拉菜单的下拉行为:

Simply try to change Dropdown behavior of your dropdown :
private void dataTreeListView1_CellEditStarting(object sender, CellEditEventArgs e)
{
    comboBox1.DropDownStyle = ComboBoxStyle.Simple;
}


这篇关于如何在DataTreeListView中编辑项目时将TextBox转换为ComboBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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