Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. find listviewitems with keyboard entries

find listviewitems with keyboard entries

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b43r_3oo3
    wrote on last edited by
    #1

    hello, i want code following scenario i've got a listview with many entries. when the user write "tom" (with the keyboard) the programm should find the first entry with tom and mark this entry. have somebaody an idear? greetings from germany - can u rate by the way my english preferences???

    C 1 Reply Last reply
    0
    • B b43r_3oo3

      hello, i want code following scenario i've got a listview with many entries. when the user write "tom" (with the keyboard) the programm should find the first entry with tom and mark this entry. have somebaody an idear? greetings from germany - can u rate by the way my english preferences???

      C Offline
      C Offline
      Cristina Rodriguez Garcia
      wrote on last edited by
      #2

      I have something similar handling keypress event of the control, a combobox in my case. Although not is a "beautiful" code, it works fine enough for my problem, find the first letter entry. I hope you can modify it for your owm problem solution: Private Sub ComboBoxMacge_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress Try Dim cb As ComboBox = CType(sender, ComboBox) Dim findString As String = String.Empty If (Not e.KeyChar.IsLetter(e.KeyChar, 0)) Then Exit Sub findString = Char.ToUpper(e.KeyChar) If cb.DropDownStyle <> ComboBoxStyle.DropDownList Then If cb.SelectedText <> cb.Text Then findString = cb.Text & Char.ToUpper(e.KeyChar) End If End If Dim IDX As Integer = -1 With cb Dim ELE As Integer = 0 Dim R As DataRow Dim DW As DataRow() = Nothing Try DW = CType(.DataSource, DataRow()) Catch Try DW = CType(.DataSource, DataTable).Select() Catch ex As Exception End Try End Try If DW Is Nothing Then Dim s As String For Each s In cb.Items ' Se distinguen los que tienen codigo o los que no: Dim idxGuion As Integer = s.IndexOfAny("-") Dim pos As Integer If idxGuion < 0 Then ' no hay guion pos = 0 Else pos = idxGuion + 2 End If If s.IndexOf(findString) = pos Then IDX = ELE Exit For End If ELE += 1 Next Else For Each R In DW ' Se distinguen los que tienen codigo o los que no: Dim idxGuion As Integer = R(cb.DisplayMember).IndexOfAny("-") Dim pos As Integer If idxGuion < 0 Then ' no hay guion pos = 0 Else pos = idxGuion + 2 End If

      B 1 Reply Last reply
      0
      • C Cristina Rodriguez Garcia

        I have something similar handling keypress event of the control, a combobox in my case. Although not is a "beautiful" code, it works fine enough for my problem, find the first letter entry. I hope you can modify it for your owm problem solution: Private Sub ComboBoxMacge_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress Try Dim cb As ComboBox = CType(sender, ComboBox) Dim findString As String = String.Empty If (Not e.KeyChar.IsLetter(e.KeyChar, 0)) Then Exit Sub findString = Char.ToUpper(e.KeyChar) If cb.DropDownStyle <> ComboBoxStyle.DropDownList Then If cb.SelectedText <> cb.Text Then findString = cb.Text & Char.ToUpper(e.KeyChar) End If End If Dim IDX As Integer = -1 With cb Dim ELE As Integer = 0 Dim R As DataRow Dim DW As DataRow() = Nothing Try DW = CType(.DataSource, DataRow()) Catch Try DW = CType(.DataSource, DataTable).Select() Catch ex As Exception End Try End Try If DW Is Nothing Then Dim s As String For Each s In cb.Items ' Se distinguen los que tienen codigo o los que no: Dim idxGuion As Integer = s.IndexOfAny("-") Dim pos As Integer If idxGuion < 0 Then ' no hay guion pos = 0 Else pos = idxGuion + 2 End If If s.IndexOf(findString) = pos Then IDX = ELE Exit For End If ELE += 1 Next Else For Each R In DW ' Se distinguen los que tienen codigo o los que no: Dim idxGuion As Integer = R(cb.DisplayMember).IndexOfAny("-") Dim pos As Integer If idxGuion < 0 Then ' no hay guion pos = 0 Else pos = idxGuion + 2 End If

        B Offline
        B Offline
        b43r_3oo3
        wrote on last edited by
        #3

        first of all thx i think i will modify this with a timer. when i'm done i'll post it in the articles.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups