We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

A couple Virtual Grid questions

Thread ID:

Created:

Updated:

Platform:

Replies:

46910 Jul 24,2006 06:58 PM Aug 10,2006 12:57 PM Windows Forms 3
loading
Tags: GridControl
Richard Butler
Asked On July 24, 2006 06:58 PM

Hello,
I searched for info on these but either got too many results that weren''t actually addressing my (very basic) questions or got no results at all. I''m sure there are threads answering these but I can''t find them. Any direct answers or thread links would be appreciated. Here goes:

1. How would I go about having an AddNew row in my virtual grid? I''m thinking something like:

-> Specify one more row than I have in my DS.
-> return default values or null values for cells in that row when queried.
-> When I get an update to a cell in that row, add a row to my DS and append a row to the grid.

Is this the ''right'' way? Or is there a better way to go about this?



2. How would I go about implementing alternating row background colors? Would I have to update the styleinfo for each row upon query if it''s the row header? I think this would work but it seems like ''the hard way''.



3. How would I set the background color for the current cell upon the cursor entering it? Honestly, I didn''t get to searching for this one, but I''m throwing it in.

Thanks in advance!

Administrator [Syncfusion]
Replied On July 25, 2006 02:23 AM

Hi Rich,

1. Virtual grid just reflects whatever in your datasource. For adding / removing row, you need to add it in the datasource. Refer to the attached sample that demonstrates to add new row with a help of the BindingManagerBase.

2. In the PrepareViewStyleInfo event handler, add the below code, for having alternating background colors for rows.

if(e.RowIndex > 0 && e.ColIndex > 0 && e.RowIndex % 2 == 1)
e.Style.BackColor = Color.LightBlue;
else
e.Style.BackColor = Color.DodgerBlue;

3. To have background color for the current cell upon cursor entering, PrepareViewStyleInfo event will help in doing it.

GridCurrentCell cc = this.gridControl1.CurrentCell;
if(e.RowIndex == cc.RowIndex && cc.IsEditing)
{
e.Style.BackColor = Color.LightYellow;
}

Here is a sample demonstrating the above mentioned features.
 VirtualGridSample.zip

Let us know if you need any further assistance.
Regards,
Rajagopal

Administrator [Syncfusion]
Replied On July 25, 2006 09:44 AM

Thanks Rajagopal,
I will look at your sample and report back what happens.

Administrator [Syncfusion]
Replied On August 10, 2006 12:57 PM

Hi, your suggestions for the alt. colors and backcolor in editing were spot-on (well, there''s some quirkiness with when the cells are color related to the latter but I''ll get back to you when I have a chance to investigate).

I went a different direction with the new row because what I wanted was a AddNew row even before there was any data and I wanted that a new addnew row once the user edited that last row. I got it working, so no worries!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;