Datagrid Scrollbar Disappearing

Posted on 2006-06-06
Last Modified: 2012-08-13
Problem: The scrollbar of my datagrid disappears intermittently; I get no error messages and have no problem using the datagrid except I would have to use Down Arrow to go to the row that is not visible in the datagrid area.  I also have a situation where I get a scrollbar on the datagrid even when the rows are not enough to fill the datagrid.  In the later case, if I click on the scroll bar, I get an error "'-13'is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'"

-- I have 1 datatable that gets the SQL results from the database every 30 seconds (Timer Interval)
-- On the form, I have 3 groups of radio buttons and 1 datagrid.  Based on the radio buttons selected, the datatable filters to the appropriate rows needed for the user on the datagrid.  
-- Right before the data table filter changes or refreshes, I set the datagrid to to nothing and refresh.  However, as soon as the filter changes and refreshing has taken effect, I set the datagrid to the datasource (The DataTable).

I have no problem with the filtering or refreshing part so far, but I have problem when the scrollbar dissapearing occassionally or appearing when not necessary (usually occurs when filter view is changed to lesser rows).

Please help me asap, I have to fix this problem within two days.  If you need more info, please let me know.  

Thank you.    
Question by:sargam78
    LVL 12

    Accepted Solution

    >I have no problem with the filtering or refreshing
    It seems a refreshing problem. Do you refresh even the scrollbar and the panel of the datagrid?
    LVL 9

    Expert Comment

    i usually have no need to set the datgrid to nothing... Can you not use a bind you grid to a dataview and apply the filters to that? then point the dataview at the new datatable... Dataview should then refresh itself...
    LVL 9

    Assisted Solution

    Ill type it without the gibberish eh?

    i usually have no need to set the datgrid to nothing... Can you not use bind your grid to a dataview and apply the filters to that dataview? then point the dataview at the new datatable as required... Datagrid should then refresh itself...

    Author Comment

    I apologize for the late reply...I'd like to thank you guys for sending your knowledgeable comments.  However, I was able to solve the issue by setting the SetDataBinding property to nothing before the filter changed and then assign the datatable to the datagrid.SetBinding property after the data table filter took place. I have done the same in the refresh code.  In another words, I have basically reset the datagrid.setDataBinding property everywhere in my code where the datatable rows change so the datagrid can sync itself to the datatable everytime.  

    General example:
    '----------- AutoRefresh code -------->
    datagrid.SetDataBinding(Nothing, Nothing)
    datagrid.DataSource = Nothing

    'update existing rows in datatable
    'import new row in datatable

    datagrid.SetDataBinding(DataTable, "")

    '----------- Filter code -------->
    datagrid.SetDataBinding(Nothing, Nothing)
    datagrid.DataSource = Nothing

    'filter the DT with whatever criteria is selected from the radiobuttons
          DataTable.DefaultView.RowFilter = m_Filters.QueueFilterString
          DataTable.DefaultView.Sort = "ColumnA ASC, ColumnB ASC"

    datagrid.SetDataBinding(DataTable, "")

    I do not refresh the scrollbar or the panel of the datagrid.  The dynamic scrollbar that comes with the datagrid object is what I always used in my code.

    Thank you for your participation.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now