DatagridView中的TextBox AutoComplete [英] TextBox AutoComplete in DatagridView
问题描述
大家好,
我在datagridview控件中遇到文本框自动完成问题。我想在这里发生的是仅启用datagridview第1列中的自动完成功能,并且应禁用其余列(2,3,依此类推),自动完成功能。我测试时自动完成工作正常,但遗憾的是,当从指定的列(第1列)触发自动完成时,它也可以与其他列单元格一起工作,就好像自动完成对datagridview中的所有单元格都可用,即使我在我的验证中指定的仅为columnIndex = 1 ...我希望文本框自动完成禁用为col2,3,依此类推,等等。请帮帮我们。
下面是我在datagridview_EditingControlShowing事件中使用的代码:
Private Sub dgvPOItems_EditingControlShowing(sender as Object ,e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)处理dgvPOItems.EditingControlShowing
Dim TX As TextBox = CType(e.Control,TextBox)
如果dgvPOItems.CurrentCell.ColumnIndex = 1那么
如果Not IsNothing(TX)那么
TX.AutoCompleteCustomSource = gacInventoryItemsLookUp
TX.AutoCompleteMode = AutoCompleteMode.SuggestAppend
TX.AutoCompleteSource = AutoCompleteSource.CustomSource
结束如果
Else
TX =没有
结束如果
结束Sub
结束如果
注意:gacInventoryItemsLookUp是在程序初始化时提供的。
谢谢,
Hi Everyone,
I am having trouble with textbox autocomplete in my datagridview control. What I want to happen here is to enable the autocomplete in datagridview column 1 only and the rest columns (2,3, so on, so forth), autocomplete feature should be disabled. The autocomplete works fine when I tested it, but unfortunately, when the autocomplete was triggered from the specified column (column 1), it also worked with the other column cells as if the auto complete is available to all the cells in datagridview even if I specified in my validation is columnIndex = 1 only... I want the textbox autocomplete disabled to col2,3, so on, so forth cells. Please help me out guys.
Below is the code I used in my datagridview_EditingControlShowing event:
Private Sub dgvPOItems_EditingControlShowing(sender As Object, e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvPOItems.EditingControlShowing
Dim TX As TextBox = CType(e.Control, TextBox)
If dgvPOItems.CurrentCell.ColumnIndex = 1 Then
If Not IsNothing(TX) Then
TX.AutoCompleteCustomSource = gacInventoryItemsLookUp
TX.AutoCompleteMode = AutoCompleteMode.SuggestAppend
TX.AutoCompleteSource = AutoCompleteSource.CustomSource
End If
Else
TX = Nothing
End If
End Sub
End If
Note: gacInventoryItemsLookUp is supplied upon program initialization.
Thanks,
推荐答案
试试
在datagridview C#中自动完成 [< a href =http://www.codeproject.com/Questions/442598/Auto-complete-in-datagridview-Csharptarget =_ blanktitle =New Window> ^ ]
http://social.msdn.microsoft.com/Forums/windows/en-US/b0a6ea52-a4ed-4bbb-8682-b25fddfa6e5f/autocomplete-in-datagridview?forum=winformsdatacontrols [ ^ ]
嗨大家好,
我自己解决了麻烦。我希望每个人都能参加我的下一个主题。
谢谢
Hi Guys,
I resolved my trouble myself. I hope everyone will participate on my next thread.
Thanks
这篇关于DatagridView中的TextBox AutoComplete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!