Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagridview display issue
 

Datagridview display issue

Hi,

I'm having some trouble with the the refresh of datagridview.

I used datagridview to show some financial data. As my page is pretty long, this datagridview is initially out of the view area. So I have to use scroll bar to bring it up. But when I scrolled to it, the display of the datagridview is somehow messed up (As shown in the following image). If I start to click on the rows, then the display will refresh and everything works fine.I tried to call datagridview.refresh() but it doesn't work.

Ihave a similar datagridviewon another page andit's within the initial view area. That datagridviewdoesn't have this problem. so I suspect this is related to the scroll.

Is there some thing I can do to resolve this?

Thanks,

liufuhu

liufuhu  Tuesday, March 20, 2007 6:04 PM

Found the problem with my control:

I left the background color of the cells as the default one: "Transparent". This has messed up the display when I scroll to see my control. After I changed the BG color to "White", everything works fine.

Thanks,

liufuhu

liufuhu  Monday, April 02, 2007 4:47 PM
Could you paste some sample code for reproducing this? You can generate some dummy data into a DataTable.
Ting Wang  Friday, March 23, 2007 2:35 AM

Hi,

Thanks for the reply. My code is very simple:

dgvPeer1.Rows.Clear();

dgvPeer2.Rows.Clear();

string[] row10 = { "", "", "", "", "", "", "", "", "", "" };

string[] row11 = { "", "", "", "", "", "", "", "", "", "" };

string[] row12 = { "", "", "", "", "", "", "", "", "", "" };

string[] row13 = { "", "", "", "", "", "", "", "", "", "" };

string[] row14 = { "", "", "", "", "", "", "", "", "", "" };

dgvPeer1.Rows.Add(row10);

dgvPeer1.Rows.Add(row11);

dgvPeer1.Rows.Add(row12);

dgvPeer1.Rows.Add(row13);

dgvPeer1.Rows.Add(row14);

string[] row20 = { "", "", "", "", "", "", "", "", "", "" };

string[] row21 = { "", "", "", "", "", "", "", "", "", "" };

string[] row22 = { "", "", "", "", "", "", "", "", "", "" };

string[] row23 = { "", "", "", "", "", "", "", "", "", "" };

string[] row24 = { "", "", "", "", "", "", "", "", "", "" };

dgvPeer2.Rows.Add(row20);

dgvPeer2.Rows.Add(row21);

dgvPeer2.Rows.Add(row22);

dgvPeer2.Rows.Add(row23);

dgvPeer2.Rows.Add(row24);

dgvPeer1.Refresh();

dgvPeer2.Refresh();

But I don't know whether this code can reproduce the issue just as is, because I think part of the reason for the issue is that the two datagridviews are out of the current view at the very beginning. I have other datagridviews in my project and they all work fine.

Also I don't know whether I can attach an image on this forum. If so it will be much easier to illustrate the issue. Last time I tried to paste the screenshot into the message but it didn't work.

Thanks for the help,

liufuhu

liufuhu  Monday, March 26, 2007 6:47 PM

Found the problem with my control:

I left the background color of the cells as the default one: "Transparent". This has messed up the display when I scroll to see my control. After I changed the BG color to "White", everything works fine.

Thanks,

liufuhu

liufuhu  Monday, April 02, 2007 4:47 PM

You can use google to search for other answers

Custom Search

More Threads

• Visual Studio and MSAccess
• Adding,updating and deleting rows on a datagridview
• Custom control with DataSource property
• [C#]need help to write in database the datagridview rows text
• [Answered] getting data from a datagridview cell
• Clear a DataSource, of a List-Bound Control
• Can not add references to a managed c++ project in visual studio 2005
• Problem With DataSource
• Datagrid Cell Keypress
• sql command and the dataset