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.
Syncfusion Feedback

problems with row index

Thread ID:

Created:

Updated:

Platform:

Replies:

52746 Dec 4,2006 07:35 AM UTC Dec 18,2006 08:40 AM UTC Windows Forms 9
loading
Tags: GridControl
Mirza Imran Nazir
Asked On December 4, 2006 07:35 AM UTC

Hi
I'm working on virtual grid. I add a new row in the grid at specific value encountered in a specific cell. But when I try to save the value in the virtual data source for the newly inserted row, its ok, but throw an exception of rowIndex out of bound after leaving the QueryColCount event handler.
I've attached the zip file for the solution. Someone's suggestion in the context is needed.

NOTE: Try WinRAR to extract the attached file.

Thansk.

VirtualGridDemo.zip

Administrator [Syncfusion]
Replied On December 4, 2006 09:13 AM UTC

Hi,

The reason is that GridData.RowCount property is not set properly in a grid. You can use this code snippet to set Data.RowCount property.

void Grid_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
try
{
if (e.RowIndex != -1 && e.ColIndex != -1)
{
RowObject currentRowObject = (RowObject)((VirtualDataSource)Grid.Tag).RowObjects[e.RowIndex - 1];
string textToSave = e.Style.Text;
((RowElement)currentRowObject.RowElements[e.ColIndex - 1]).RowElementData = textToSave;
if (textToSave == "OR" || textToSave == "AND")
{
this.gridDataSource.AddNewRowObject();
this.Grid.ResetVolatileData();
this.Grid.Data.RowCount = ((VirtualDataSource)Grid.Tag).RowCount;
this.Grid.RefreshRange(GridRangeInfo.Row(e.RowIndex + 1));
}
}
}
catch (Exception ex)
{
throw ex;
}
}

Here is a modified sample.
VirtualGridDemo.rar

Best Regards,
Haneef

Mirza Imran Nazir
Replied On December 4, 2006 10:08 AM UTC

Hi Mr. Haneef

I have made the changes that you have suggested to me, but the same problem still persists. Would you please try running this solution on your machine? I hope that you will get to the problem and suggest me the proper solution.

Regards
Mirza Imran Nazir

>Hi,

The reason is that GridData.RowCount property is not set properly in a grid. You can use this code snippet to set Data.RowCount property.

void Grid_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
try
{
if (e.RowIndex != -1 && e.ColIndex != -1)
{
RowObject currentRowObject = (RowObject)((VirtualDataSource)Grid.Tag).RowObjects[e.RowIndex - 1];
string textToSave = e.Style.Text;
((RowElement)currentRowObject.RowElements[e.ColIndex - 1]).RowElementData = textToSave;
if (textToSave == "OR" || textToSave == "AND")
{
this.gridDataSource.AddNewRowObject();
this.Grid.ResetVolatileData();
this.Grid.Data.RowCount = ((VirtualDataSource)Grid.Tag).RowCount;
this.Grid.RefreshRange(GridRangeInfo.Row(e.RowIndex + 1));
}
}
}
catch (Exception ex)
{
throw ex;
}
}

Here is a modified sample.
VirtualGridDemo.rar

Best Regards,
Haneef

VirtualGridDemo0.zip

Administrator [Syncfusion]
Replied On December 4, 2006 10:55 AM UTC

Hi Mirza,

Thanks for the update.

I am afraid I am not able to reproduce this issue. I have tested a modified sample on my system which has "Essential version 4.3 +Windows XP sp2 +.Net 2.0" installed. Could you please try running the same at your end and send me back the modified sample if still the problem exists? Also please let me know about the current version of Essential Studio/.NET framework you are using.

If you give more information about this issue, we will try debugging here.

Here is a modified sample.
VirtualGridDemo.rar

Here is a testing video clip.
TestingVideoClip.rar

Best Regards,
Haneef

Mirza Imran Nazir
Replied On December 4, 2006 11:32 AM UTC

Hi,

Thankyou very much Mr. Haneef, your modified code has resolved my problem. Now, would you please tell me when and where to call BeginUpdate and EndUpdate events while maximizing or resizing the virtual grid?

Best Regards,
Mirza Imran Nazir

Administrator [Syncfusion]
Replied On December 6, 2006 12:20 PM UTC

Hi Mirza,

The BeginUpdate/EndUpdate calls may avoid flickers in some situations. You can handle the Layout event of the grid to call the BeginUpdate and call EndUpdate in SizeChanged event. Please try the suggestion and let me know if this helps. Here is a code snippet.

private void gridControl1_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{ this.gridControl1.BeginUpdate(); }

private void gridControl1_SizeChanged(object sender, System.EventArgs e)
{this.gridControl1.EndUpdate(true); }

Best Regards,
Haneef

Ubaid
Replied On December 8, 2006 01:12 PM UTC

Hi Haneef .... Its not working
"gridControl1_Layout" is fired only once at the startup/loading and "gridControl1_SizeChanged" is not fired until size of the grid is changed.

Em attaching a demo project ... kindly have a look at it and suggest me some good solution.

Steps To Run The Project:
1) Run the application.
2) Select AND/OR from the drop down in 2nd row.
3) Foucs out of the cell
4) Click on "New" option in the toolstrip
6) A '+' sign will appear in the first row, try expanding/collapsing and you will note lot of flickering.

Filter_Grid.zip

Administrator [Syncfusion]
Replied On December 11, 2006 07:31 AM UTC

Hi Ubaid,

Try commenting Refresh() method in grid's SaveCellInfo event and also you can call Invalidate() method followed by a Update() to repaint the cell in the MergeXtraCells method. It should be a bit better.

Here is a modified sample.
Filter_Grid.zip

Best Regards,
Haneef

Ubaid
Replied On December 18, 2006 05:50 AM UTC

Hi Haneef ... The Solution you proposed me was not an appropriate solution as it does not reflect the updations made to grid until you refresh it. However i had come up with a good solution which i want to share with you. Em attaching a demo, pleae have a look at it.

Filter_Grid0.zip

Administrator [Syncfusion]
Replied On December 18, 2006 08:40 AM UTC

Hi Ubaid,

Thank you for response. I hope you enjoyed sharing information with us. Please open a new forum thread for further queries.

Thanks for your interest in our products.

Best regards,
Haneef

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.

Warning Icon 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.Close Icon

;