程式碼:
Private Sub 明細編輯_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles othing,
'加減項
Dim columnID As New DataGridViewComboBoxColumn()
columnID.HeaderText = "加減項"
columnID.Name = "加減項"
columnID.DataPropertyName = "加減項"
'columnID.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
'columnID.FlatStyle = FlatStyle.Flat
'columnID.ValueType = GetType(Decimal)
columnID.DataSource = dt加減項
columnID.DisplayMember = "中文"
columnID.ValueMember = "加減"
'columnID.Items.AddRange(New Object() {0, 1, 2, 3}) '{"TT", "TF", "2F"})
DataGridView1.Columns.Add(columnID)
End Sub
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
If TypeOf e.Control Is DataGridViewComboBoxEditingControl Then
CType(e.Control, ComboBox).DropDownStyle = ComboBoxStyle.DropDown
CType(e.Control, ComboBox).AutoCompleteSource = AutoCompleteSource.ListItems
CType(e.Control, ComboBox).AutoCompleteMode = AutoCompleteMode.SuggestAppend
End If
End Sub
參考:
[C#] DataGridView ComboBox 欄位設定自動完成
AutoComplete ComboBox in DataGridView using C#.net Windows Application
C# » How to Create Editable ComboBox in DataGridView
[C#][WinForm]DataGridView中使DataGridViewComboBox可编辑
DataGridView - how to create combobox cell with DisplayStyle ComboBoxList?
看了一篇介绍如何自定义datagridview列的文章,写了一个可输入的combobox列
译文:构建DataGridView的定制NumericUpDown单元格(Cell)和表格列(Column)
扩展 DataGridView 的功能(二)
ProcessCmdKey方法让DataGridView按Enter回车键转到下一列的格
(讓ComboBoxColumn在下拉選項時, 解決出現二種模式...)
Combobox AutoCompleteMode.Suggest Issue (不能DropDown又用Suggest)
The operating system might limit the number of custom strings that it can display at once. For strings that contain a forward slash (/) or backward slash (\), automatic completion appends all characters only up to and including the slash. 只貼上到斜線
沒有留言:
張貼留言