CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Posts
    1

    How to scroll the client area of a CListBox ?

    How can i automatically scroll the cleint area of a CListBox ?

    The problem occurs every time the method "DeleteString()" of the CListBox is called.
    The method scrolls the client area back to the top of the ListBox.
    So i have to scroll it back where it was before "DeleteString()".
    SetScrollPos(..) only sets the position of the scroll bar (the thumb) but it doesn´t scroll the client area of the CListBox.
    The best way would be to diasble scrolling to the top at the end of "DeleteString()".
    If this is not possible i have to reset the old positon of the client area.
    But how ?

    MfG stepfa



  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: How to scroll the client area of a CListBox ?

    int nIndex = lb.GetTopIndex();
    if (nIndex != LB_ERR)
    {
    if (nIndexToDelete <= nIndex)
    nIndex--; // Adjust it so the same item stays selected
    }
    lb.DeleteString(nIndextoDelete);
    lb.SetTopIndex(nIndex);


    HTH,
    Chris


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