在c#中使用Combobox控件和DataGridView [英] Using Combobox control with DataGridView in c#
问题描述
大家好,
我使用的DataGridView有5行2列。
这个用于用户输入。
第0列是TextBox
第1列是Combobox / TextBox / DateTime控件。
每五行代表5种不同类型的值,例如,
第0列第0行是输入性别
第1行第0列是输入国籍
第0列第2行是输入日期
第1列的每一行都是相应类型的控制也接受价值。
我怎样才能实现这个目标?
提前谢谢
Jim
Hi all,
I am using a DataGridView which has 5 rows and 2 columns.
This is meant to be used for user input.
column 0 is of TextBox
column 1 is of Combobox/TextBox/DateTime control.
The each five row means 5 different type of values like,
row 0 of column 0 is "Enter Gender"
row 1 of column 0 is "Enter Nationality"
row 2 of column 0 is "Enter Date"
and each row of column 1 is to be the respective type of control and accept the values too.
How can i achieve this?
Thanks in advance
Jim
推荐答案
你决不能这样做。同一列中的单元格必须是相同的类型。我的意思是你不能在这种情况下使用DataGridViewComboBoxColumn,DataGridViewTextBoxColumn类。
你可以使用扩展列表视图。通过使用这个逻辑,你也可以扩展datagridview。
ListView子项的就地编辑 [ ^ ]
No way you can't do it. Cells in same column must be same type. I mean you cannot use DataGridViewComboBoxColumn, DataGridViewTextBoxColumn classes for this situation.
You can use an extended listview for this. By using this logic you can extend datagridview too.
In-place editing of ListView subitems[^]
这篇关于在c#中使用Combobox控件和DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!