CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    [RESOLVED] Scroll Datagridview to programtically selected item.

    I have a single select datagridview listing several hundred 'Clients' , and a Search box where Client Id, Name or Account number can be entered to select a relevant Client..

    Once the search has been completed i select the relevant client on the datagridview using the code in this Thread

    The problem i'm having now is that when the selected item is further down the list.. the DGV does not scroll to show the selected item..

    Is there a way to force the DGV to show the programatically selected item..

    Thanks

    Gremmy...
    Last edited by GremlinSA; October 29th, 2009 at 09:21 AM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Scroll Datagridview to programtically selected item.

    Ahh i found a solution....

    Code:
                For Each Row As DataGridViewRow In DGVConsumer.Rows
                    If KeyValue = Row.Cells("ConsumerID").Value Then
                        DGVConsumer.Rows(Row.Index).Selected = True
                        DGVConsumer.FirstDisplayedScrollingRowIndex = Row.Index
                        Exit For
                    End If
                Next
    And this works like a charm ...

    Gremmy.....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured