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. Selected row always visible in datagridview research

Selected row always visible in datagridview research

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 31 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.
  • M Offline
    M Offline
    medi dimie
    wrote on last edited by
    #1

    I want to perform a search in a DataGridView. The search command is working, but I have a problem: a row always remains visible in the DataGridView even if it does not correspond to the search criteria. This row is always the last selected one. I have tried using 'ClearSelection,' and no rows are selected/highlighted, but the problem persists—the same row is still visible. this is my code :

    Private Sub TxtboxReserch_TextChanged(sender As Object, e As EventArgs) Handles TxtboxReserch.TextChanged
    If TxtboxReserch.Text = "" Then
    For i = 0 To DataGridView1.RowCount - 1
    DataGridView1.Rows(i).Visible = True
    Next
    Else
    DataGridView1.ClearSelection()
    For i = 0 To DataGridView1.RowCount - 1
    Try
    DataGridView1.Rows(i).Visible = (DataGridView1.Rows(i).Cells(1).Value Like "*" + TxtboxReserch.Text + "*")

               Catch ex As Exception
    
               End Try
           Next
       End If
    

    End Sub

    L 1 Reply Last reply
    0
    • M medi dimie

      I want to perform a search in a DataGridView. The search command is working, but I have a problem: a row always remains visible in the DataGridView even if it does not correspond to the search criteria. This row is always the last selected one. I have tried using 'ClearSelection,' and no rows are selected/highlighted, but the problem persists—the same row is still visible. this is my code :

      Private Sub TxtboxReserch_TextChanged(sender As Object, e As EventArgs) Handles TxtboxReserch.TextChanged
      If TxtboxReserch.Text = "" Then
      For i = 0 To DataGridView1.RowCount - 1
      DataGridView1.Rows(i).Visible = True
      Next
      Else
      DataGridView1.ClearSelection()
      For i = 0 To DataGridView1.RowCount - 1
      Try
      DataGridView1.Rows(i).Visible = (DataGridView1.Rows(i).Cells(1).Value Like "*" + TxtboxReserch.Text + "*")

                 Catch ex As Exception
      
                 End Try
             Next
         End If
      

      End Sub

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You already posted this question once; please do not repost.

      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