📄 defaultvb.aspx.vb
字号:
Imports System
Imports System.Data
Imports System.IO
Imports Telerik.QuickStart
Imports Telerik.WebControls
Namespace Telerik.ComboboxExamplesVB.ClientEvents
'/ <summary>
'/ Summary description for _Default.
'/ </summary>
Public Class DefaultVB
Inherits XhtmlPage
Protected WithEvents RadComboBox1 As RadComboBox
Private dictionaryWords As New DataTable()
Private Sub LoadData()
Dim tdfPath As String = Server.MapPath("~/Combobox/Data/en-US.tdf")
If Cache("dictionaryWords") Is Nothing Then
Dim words As New DataTable("words")
Dim column As DataColumn = words.Columns.Add("word")
Dim word As String = [String].Empty
Dim sr As StreamReader = File.OpenText(tdfPath)
word = sr.ReadLine()
While Not (word Is Nothing)
Dim tempWord As String = word.Trim().Split(":"c)(0)
words.Rows.Add(New String() {tempWord})
word = sr.ReadLine()
End While
sr.Close()
Cache("dictionaryWords") = words
End If
dictionaryWords = CType(Cache("dictionaryWords"), DataTable)
End Sub 'LoadData
Private Sub RadComboBox1_ItemsRequested(o As Object, e As RadComboBoxItemsRequestedEventArgs) Handles RadComboBox1.ItemsRequested
LoadData()
RadComboBox1.Items.Clear()
Dim [text] As String = e.Text
Dim rows As DataRow() = dictionaryWords.Select(("word LIKE '" + [text] + "*'"))
Dim itemsPerRequest As Integer = 20
Dim itemOffset As Integer = e.NumberOfItems
Dim endOffset As Integer = itemOffset + itemsPerRequest
If endOffset > rows.Length Then
endOffset = rows.Length
End If
Dim i As Integer
For i = itemOffset To endOffset - 1
RadComboBox1.Items.Add(New RadComboBoxItem(rows(i)("word").ToString()))
Next i
e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), rows.Length.ToString())
End Sub 'RadComboBox1_ItemsRequested
Private Sub Page_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
LoadData()
End If
End Sub 'Page_Load
Protected Overrides Sub OnInit(e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub 'OnInit
'/ Required method for Designer support - do not modify
'/ the contents of this method with the code editor.
'/ </summary>
Private Sub InitializeComponent()
End Sub 'InitializeComponent
End Class 'DefaultVB
End Namespace 'Telerik.ComboboxExamplesVB.ClientEvents
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -