本文介绍了在窗体加载时在DataGridView中插入一次DataGridViewComboBoxColumn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面有此代码
I have this code below
cmb.HeaderText = "Promoted To"
cmb.Name = "cmb"
cmb.MaxDropDownItems = 4
cmb.items.add("Class 2")
cmb.items.add("Class 3")
DataGridView.Columns.Insert(4, cmb)
此代码处于表单加载状态,每次我加载表单时,都会将DataGridViewComboBoxColumn插入位置4.但是我希望将DataGridViewComboBoxColumn插入一次,如果已经退出,则不应再次插入.
this code is at form load and each time i load the form, the DataGridViewComboBoxColumn is inserted at position 4.but i want the DataGridViewComboBoxColumn to be inserted once and if it already exit it should not be inserted again.
推荐答案
cmb.HeaderText = "Promoted To"
cmb.Name = "cmb"
cmb.MaxDropDownItems = 4
cmb.items.add("Class 2")
cmb.items.add("Class 3")
DataGridView.Columns.Insert(4, cmb)
如果
End If
If DataGridView.Columns.Count < 8 Then
Dim cmb As New DataGridViewComboBoxColumn()
cmb.HeaderText = "Promoted To"
cmb.Name = "cmb"
cmb.MaxDropDownItems = 4
DataGridView.Columns.Insert(4, cmb)
End If
这篇关于在窗体加载时在DataGridView中插入一次DataGridViewComboBoxColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!