面对问题时,从datagridview单元格中的combobox中选择一个值时,必须在同一datacell中替换为文本框
下面是我的ComboBox值源函数
If e.ColumnIndex >= 0 And e.RowIndex >= 0 Then
Dim row1 = New ArrayList()
row1.AddRange(New Integer() {1, 2})
p.Items.AddRange(row1.ToArray())
DataGridView1(e.ColumnIndex, e.RowIndex) = p
End If
下面的功能是在选择ComboBox的值之后,我们必须将ComboBox更改为同一单元格中的TextBox
Dim combo1 As ComboBox = CType(sender, ComboBox)
If combo1.SelectedIndex = 0 Then
Dim Datas As New DataGridViewTextBoxCell
Datas.Value = "S"
DataGridView1.CurrentCell.Value = Datas
End If
,但ComboBox未替换为文本框。
得到答复是高度赞赏的!!!
below is my comboBox value populate function
If e.ColumnIndex >= 0 And e.RowIndex >= 0 Then
Dim row1 = New ArrayList()
row1.AddRange(New Integer() {1, 2})
p.Items.AddRange(row1.ToArray())
DataGridView1(e.ColumnIndex, e.RowIndex) = p
End If
below function is for after selecting value from comboBox, we have to change that combobox to textbox in same cell
Dim combo1 As ComboBox = CType(sender, ComboBox)
If combo1.SelectedIndex = 0 Then
Dim Datas As New DataGridViewTextBoxCell
Datas.Value = "S"
DataGridView1.CurrentCell.Value = Datas
End If
but comboBox have not replacing to textBox.
getting reply is highly appreciated!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是如此错误:
您正在创建一个新单元格,然后尝试将其分配给现有单元格的
value
。这有什么意义?您不能在单元格内有一个单元格,也不能神奇地更改单元格的类型。如果您想要一个不同类型的单元格,则需要用该类型的新单元格代替现有单元格:This is so wrong:
You are creating a new cell and then trying to assign that to the
Value
of the existing cell. How does that make sense? You can't have a cell inside a cell and you can't magically change the type of a cell. If you want a cell of a different type then you need to replace the existing cell with a new cell of that type: