Hello,
I am using .NET v1.1, Syncfusion v2.0.5.1.
I want to populate the grid in OnQueyCellInfo event (virtual grid) from another class. I have set the colwidths initially as constant (that i do not want to change), rather i would like to change the rowheights based on the data getting populated. I handled the QueryRowHeights and SaveRowHeights events to store the calculated height in a integer array. The issue is if I refresh the grid the row is populated and the row height is set to default size and then resize to fit based on the content. The grid is flickerring. how do i avoid this flickerring.
or do you have any samples for this scenario.
AD
Administrator
Syncfusion Team
July 26, 2006 01:23 PM UTC
Hi Dhans,
The flickering problem can be avoided by calling the Refresh method between the BeginUpdate() and EndUpdate() calls.
grid.BeginUpdate();
////code///
grid.EndUpdate( false );
Let me know if this helps.
Thanks,
Rajagopal
AD
Administrator
Syncfusion Team
July 27, 2006 12:30 PM UTC
Thanks for your reply Rajagopal.
Here with I am attaching the sample which produces the above said issue. If I do the refresh between begin and end updates, The grid does not resize the row heights correctly.
Click the "Fill Grid" button in the attached sample you could see the grid flicker.
Is there any work around for this issue, Or correct me if i am doing anything wrong.
Thanks,
Dhans
RowHeightResize.zip
AD
Administrator
Syncfusion Team
July 27, 2006 01:33 PM UTC
Hi Dhans,
Try calling the ResizeToFit method in button event instead of calling the Paint event. You need the first line to make sure the new row height generated by the resizetofit method is used by the grid when it redraws itself instead of any cached row heights. The last line forces the grid to redraw itself to show the new data and row height.
gridControl1.ResetVolatileData(); /////// Added.
rowheights = new int[ROW_COUNT];
this.gridControl1.RowCount = 0;
this.gridControl1.RowCount = ROW_COUNT;
SetColWidth();
gridControl1.RowHeights.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Rows(1,this.gridControl1.RowCount ));
this.gridControl1.Invalidate(); /////Added.
Let me know if this is not what you needed.
Regards,
Haneef
AD
Administrator
Syncfusion Team
July 27, 2006 01:48 PM UTC
Haneef,
I have tried calling the ResizetoFit function along with ResetVolatile and Invalidate methods in between the BeginUpdate and EndUpdate Methods.
But the result is same, I have tried by unregistering the grid paint event also that did not work.
Thanks,
Dhans
AD
Administrator
Syncfusion Team
July 28, 2006 05:55 AM UTC
Hi Dhans,
I have modified the sample as per your requirement .Please refer to the attached sample and let us know if you are trying something different.
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/RowHeightResize_eb09eae0.zip
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
July 28, 2006 08:45 AM UTC
Thanks Haneef,
If i click on the "Fill Grid" button i could see the follwing message in the console output window. What could be the cause for this
"catched at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.SetRange(Int32 from, Int32 last, Int32[] values, Boolean discardUndo) in :line 0"
Thanks,
Dhans
AD
Administrator
Syncfusion Team
July 28, 2006 08:59 AM UTC
>Thanks Haneef,
> If i click on the "Fill Grid" button i could see the follwing message in the console output window. What could be the cause for this
>"catched at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.SetRange(Int32 from, Int32 last, Int32[] values, Boolean discardUndo) in :line 0"
Also, if i scroll down with line by line then it works fine, but if i drag the scroll button down then the rows are not resized to data height. only the last row of the visible row is resized.
I have changed the range of resizing cells in VerticallScroll event to all visible cells range then the grid starts flickering, if i drag the scroll bar to below some extend.
Thanks,
Dhans
AD
Administrator
Syncfusion Team
August 1, 2006 05:59 AM UTC
Also, I have modified my sample to populate the grid with different data per row (vary the rowheights). Now, when i first click on the "Fill grid" button it populates the data, but the rowheights are not adjusted with the data present in the grid, you could see this by navigating grid down using arrow key (NOT SCROLL).
How can i set the rowheigths depending on the data populated to grid row?
Thanks,
Dhans
Mod_RowHeightResize.zip
AD
Administrator
Syncfusion Team
August 1, 2006 10:51 AM UTC
Hi Dhans,
Can you try the code below in the CurrentCellMoved event of the grid. This will help you.
GridCurrentCell cc = this.gridControl1.CurrentCell;
if(cc.MoveFromRowIndex != cc.MoveToRowIndex)
{
this.gridControl1.RowHeights.ResizeToFit(this.gridControl1.ViewLayout.VisibleCellsRange); this.gridControl1.InvalidateRange(this.gridControl1.ViewLayout.VisibleCellsRange);
}
Thanks,
Rajagopal
AD
Administrator
Syncfusion Team
August 1, 2006 10:55 AM UTC
Hi Dhans,
Can you try the code below in the CurrentCellMoved event of the grid. This will help you.
GridCurrentCell cc = this.gridControl1.CurrentCell;
if(cc.MoveFromRowIndex != cc.MoveToRowIndex)
{
this.gridControl1.RowHeights.ResizeToFit(this.gridControl1.ViewLayout.VisibleCellsRange);
this.gridControl1.InvalidateRange(this.gridControl1.ViewLayout.VisibleCellsRange);
}
Thanks,
Rajagopal