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.

Excel like scrolling effect in a Virtual Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

66572 Jul 31,2007 01:58 AM Aug 9,2007 06:35 AM Windows Forms 4
loading
Tags: GridControl
Ben Fraser
Asked On July 31, 2007 01:58 AM

Hello,

I'm using a virtual gird in V5.1.

We want to achieve an Excel like scrolling effect.

When the user clicks on the increment arrow (performing a small increment) at the extremity of the dataset we want to add new rows to the dataset dynamically. This much is fine. We then want to achieve these two things:

* After adding the new rows we would like the thumb track to remain at the end of the scroll bar - there should be no open space between the thumb track and the arrow.

* We do not want to see any ugly open space after the last column - we'd like to see part of another empty column like you get in Excel.

We've been able to either keep the thumb track at the end of the scroll bar and get the ugly open space OR have the scroll bar resize to accommodate an additional, unnecessary row at the end to get the visually appealing 'full column' effect. We cannot get both working at once.

The example provided has a suitable horizontal scroll handler setup to show adding additional rows to achieve the full column effect while getting a resizing scroll bar. Just run the sample and scroll to the right.

By commenting out line 39 of GridControlScrollingTest where the horizontal scroll handler is set you can get the ugly space at the end that is the default grid behavior.

It would be nice to have a static member variable that would take a given number of rows/columns from the QueryColCount result and use that value as the last column to display - this would give a screen full of columns.

It would be even nicer to have a setting provided that would always fill the screen with empty columns whenever there were not enough real columns available to fill the screen.

Perhaps there are other, better ideas to get around this? An already existing solution I have not found?

Thank You,
Ben

GridControlScrollingTest.zip

haneefm [Syncfusion]
Replied On July 31, 2007 07:34 PM

Hi Ben,

There is a property to control the display of the Empty rows/columns in a grid. you can use below code to display empty rows/columns in a grid

this.gridControl1.Model.Options.DisplayEmptyRows = true;
this.gridControl1.Model.Options.DisplayEmptyColumns = true;

Best Regards,
Haneef

Ben Fraser
Replied On August 1, 2007 10:01 PM

Hello,

I am using a virtual grid. I am trying to figure out when I need to add more rows/columns to my internal data set as the user scrolls so that they can expand the size of the grid as they please.

I have set the grid options DisplayEmptyColumns and DisplayEmptyRows to get a screen full of rows. I have added event handlers for the vertical scroll and horizontal scroll events. Now I want to get access to the numbers you have internally that say how many empty rows/columns you have added to fill the screen.

I am thinking that with this and the SmallChange/LargeChange values from the scrollbars I can figure out what to add to the internal dataset.

Alternatively can you give a better solution using some different variables I am not aware of.

Thanks,
Ben

Ben Fraser
Replied On August 8, 2007 08:38 PM

Hello?

Jeba S [Syncfusion]
Replied On August 9, 2007 06:35 AM

Hi Ben,

Sorry for the delay in response.

When you set the DisplayEmptyRows property of the grid, Grid draws the empty row in a clientarea(it is a clientarea only). It doesnot add any row to the grid. To get the total rowcount(displaycount+grid's row count), You need to handle the prepareviewstyleInfo event.

Please refer this code snippets:

int totalRowCount = -1;
private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if (e.RowIndex > this.gridControl1.RowCount)
{
totalRowCount = e.RowIndex;
e.Style.Enabled = false;
}
else if (totalRowCount <= this.gridControl1.RowCount)
totalRowCount = this.gridControl1.RowCount;
}
if (e.RowIndex > 0 && e.ColIndex == 0)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if (e.RowIndex > this.gridControl1.RowCount)
{
e.Style.CellType = "Static";
e.Style.ImageList = this.imageList1;
e.Style.ImageIndex = 0;
}
}
}


To make the DisplayEmptyRows as the orginal row, you need to reassign the rowcount property explictly.

this.gridControl1.RowCount = totalRowCount;


Thank you for your interest in Syncfusion Products.

Best Regards,
Jeba.


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.

;