Redraw problem with .NET Datagrid.

K

Kevin Hodgson

I'm having a strange problem with a VB.NET App, and the built in
Windows.Forms.Datagrid

I have a tabbed interface, and a DataGrid (along with other controls) on
each of my two Tabs.

If the Datagrid on my first Tab has a horizontal scrollbar automatically
drawn because the table is too wide, and I switch to the other tab and
resize the form, when I switch back to the first tab, the horizontal
scrollbar on the datagrid is in the same position it was before the resize.
The Datagrid itself however, has been resized to the fill the form's new
size, such that the Horizontal Scroll bar appears to be floating in the
middle of the Datagrid, until I resize the app form from this tab.
Unfortunately, it only occurs intermittently, and more often when the
application is used via Terminal Server/Remote Desktop on a Windows 2000
Server. I have seen it occur in debug and release mode on my Windows XP SP1
Workstation, though not as often.

I've tried adding a DataGrid.Refresh() on the Tab Switch event to get it to
redraw, but it doesn't solve the problem 100% of the time, as I say, it's
still intermittent, though it seems to occur less frequently with the
..Refresh() calls.

Has anyone else seen this sort of behaviour before, or know what could be
causing it, or a solution?

Thanks.
 
K

Ken Tucker [MVP]

Hi,

Try invalidate it instead of refresh.

Ken
----------------
I'm having a strange problem with a VB.NET App, and the built in
Windows.Forms.Datagrid

I have a tabbed interface, and a DataGrid (along with other controls) on
each of my two Tabs.

If the Datagrid on my first Tab has a horizontal scrollbar automatically
drawn because the table is too wide, and I switch to the other tab and
resize the form, when I switch back to the first tab, the horizontal
scrollbar on the datagrid is in the same position it was before the resize.
The Datagrid itself however, has been resized to the fill the form's new
size, such that the Horizontal Scroll bar appears to be floating in the
middle of the Datagrid, until I resize the app form from this tab.
Unfortunately, it only occurs intermittently, and more often when the
application is used via Terminal Server/Remote Desktop on a Windows 2000
Server. I have seen it occur in debug and release mode on my Windows XP SP1
Workstation, though not as often.

I've tried adding a DataGrid.Refresh() on the Tab Switch event to get it to
redraw, but it doesn't solve the problem 100% of the time, as I say, it's
still intermittent, though it seems to occur less frequently with the
..Refresh() calls.

Has anyone else seen this sort of behaviour before, or know what could be
causing it, or a solution?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top