共享一个输入字母定位汉字的下拉列表源代码解决办法
共享一个输入字母定位汉字的下拉列表源代码
Public Class MyChsFstChrCombo
'使用Collection保存和Combox同步的一个数据集合
Private mColItemKey As New Collection()
Private mColFstChr As New Collection
Private mColItemText As New Collection
Private mStrSelText As String
Private mBlnIsOpenTextChange As Boolean = True
'增加Item,同时增加对应的一个数据
Public Sub AddItem(ByVal iStrItem As String, ByVal iObjItemData As Object)
Dim iIndex As Int64
iIndex = cboLst.Items.Add(iStrItem)
'数据集合采用Item的Index的ToString作为关键字
mColItemKey.Add(iObjItemData, iIndex.ToString)
mColFstChr.Add(GetFirstLetter(iStrItem, False), iIndex.ToString)
mColItemText.Add(iStrItem, iIndex.ToString)
End Sub
Private Sub cboInput_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboInput.Click
If Not cboLst.DroppedDown Then cboLst.DroppedDown = True
End Sub
'返回当前选中的Item对应的数据
Public Function GetSelectItemData() As Object
Try
'没有选择的时候,通过文本匹配获得相应的数据
Dim i As Int32
For i = 0 To mColItemText.Count - 1
If Me.Text = mColItemText(i.ToString) Then Return mColItemKey(i.ToString)
Next
Return -1
Catch ex As Exception
Return -1
End Try
End Function
Public Function GetItemData(ByVal iIndex As Int64) As Object
Try
'没有选择的时候,通过文本匹配获得相应的数据
Public Class MyChsFstChrCombo
'使用Collection保存和Combox同步的一个数据集合
Private mColItemKey As New Collection()
Private mColFstChr As New Collection
Private mColItemText As New Collection
Private mStrSelText As String
Private mBlnIsOpenTextChange As Boolean = True
'增加Item,同时增加对应的一个数据
Public Sub AddItem(ByVal iStrItem As String, ByVal iObjItemData As Object)
Dim iIndex As Int64
iIndex = cboLst.Items.Add(iStrItem)
'数据集合采用Item的Index的ToString作为关键字
mColItemKey.Add(iObjItemData, iIndex.ToString)
mColFstChr.Add(GetFirstLetter(iStrItem, False), iIndex.ToString)
mColItemText.Add(iStrItem, iIndex.ToString)
End Sub
Private Sub cboInput_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboInput.Click
If Not cboLst.DroppedDown Then cboLst.DroppedDown = True
End Sub
'返回当前选中的Item对应的数据
Public Function GetSelectItemData() As Object
Try
'没有选择的时候,通过文本匹配获得相应的数据
Dim i As Int32
For i = 0 To mColItemText.Count - 1
If Me.Text = mColItemText(i.ToString) Then Return mColItemKey(i.ToString)
Next
Return -1
Catch ex As Exception
Return -1
End Try
End Function
Public Function GetItemData(ByVal iIndex As Int64) As Object
Try
'没有选择的时候,通过文本匹配获得相应的数据