Link to home
Start Free TrialLog in
Avatar of sargam78
sargam78

asked on

Datagrid Scrollbar Disappearing

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'"

Background:
-- 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.    
ASKER CERTIFIED SOLUTION
Avatar of Giant2
Giant2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sargam78
sargam78

ASKER

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
datagrid.Refresh()

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

datagrid.SetDataBinding(DataTable, "")
datagrid.Refresh()
datagrid.Update()

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

'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, "")
datagrid.Refresh()
datagrid.Update()


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.