VB.NET 给DataGridView 控件的DataGridViewComboBoxColumn类型列赋值??
给DataGridView 控件的DataGridViewComboBoxColumn类型列赋值时怎样控制其不显示下拉框。直接显示数值
Dim cell As DataGridViewComboBoxCell
cell = grdList.Rows(index).Cells("ItemsNo")
cell.Items.Add(frmItemSelNew.m_drResult.Cells("ItemsNumber").Value.Trim)
'cell.DisplayMember = frmItemSelNew.m_drResult.Cells("ItemsNumber").Value.Trim
cell.Value = frmItemSelNew.m_drResult.Cells("ItemsNumber").Value.Trim
之前用这个控件做了默认添加行了。求解????
[解决办法]
你不用DataGridViewComboBoxCell,
用DataGridViewTextBoxCell不就可以了吗?
[解决办法]
cell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
非编辑模式下就看不到下拉框了
[解决办法]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'预先在窗体画一个datagridview,在设计时添加列为四列,并将第一列设置为DataGridViewComboBoxColumn
DataGridView1.Rows.Add(5)
Dim cell As DataGridViewComboBoxCell
For i As Integer = 0 To DataGridView1.Rows.Count - 1
cell = DataGridView1.Rows(i).Cells(0)
cell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
Next
End Sub