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. Image for the cookie policy date

Performance Problem(Resize To Fit)

Hi There, Actually I am using Griddataboundgrid, and it contains 160 records,and that gird contains one column(cells) which is of type Richtext.So obviously each and every row height will be different(ofcourse not always).To load that form it is taking 16 seconds.If I just comment "this.Model.RowHeights.ResizeToFit" this method the form will load in 2 seconds.Kindly provide some solution for this.I am pasting that line of code below in quotations. I checked using Beginupdate,suspendbinding all that stuff,so kindly give some other solution. "this.Model.RowHeights.ResizeToFit(GridRangeInfo.Cells(1, 1,this.Model.RowCount,1),GridResizeToFitOptions.ResizeCoveredCells);" Regards, Manohar.

9 Replies

AD Administrator Syncfusion Team September 28, 2005 12:27 PM UTC

Manohar, try to limit the number of rows to scan: int maxRowsToScan = 100; this.Model.RowHeights.ResizeToFit(GridRangeInfo.Cells(1, 1,Math.Min(maxRowsToScan, this.Model.RowCount),1),GridResizeToFitOptions.ResizeCoveredCells); Stefan >Hi There, > > Actually I am using Griddataboundgrid, and it contains 160 records,and that gird contains one column(cells) which is of type Richtext.So obviously each and every row height will be different(ofcourse not always).To load that form it is taking 16 seconds.If I just comment "this.Model.RowHeights.ResizeToFit" this method the form will load in 2 seconds.Kindly provide some solution for this.I am pasting that line of code below in quotations. >I checked using Beginupdate,suspendbinding all that stuff,so kindly give some other solution. > > >"this.Model.RowHeights.ResizeToFit(GridRangeInfo.Cells(1, 1,this.Model.RowCount,1),GridResizeToFitOptions.ResizeCoveredCells);" > > > > >Regards, >Manohar. >


MA manohar September 28, 2005 02:05 PM UTC

Hi Stefan, see if we scan less rows than grid row count,rows which are not scanned are not resized what I mean is, row is getting set with the default height than expected(means if four lines are there it is showing only one line which fits in the default height,and rest is mystery).If that''s the case if I just comment the line which i gave you earlier, it takes only 2 seconds to load the grid(Having 160 records,means i am not resizing any row).So the total problem lies in resizing and I need to do resize of that cells.Kindly provide some other solution for this problem. Regards, Manohar.


AD Administrator Syncfusion Team September 29, 2005 12:08 AM UTC

Manohar, I misunderstood first. Sorry about that. The following code lets you size the rows on demand just before they are drawn: public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); //Listen to the IBindingList.ListChanged events instead of the //CurrencyManager events. this.gridDataBoundGrid1.UseListChangedEvent = true; this.gridDataBoundGrid1.Model.QueryRowHeight += new GridRowColSizeEventHandler(Model_QueryRowHeight); this.gridDataBoundGrid1.Model.QueryRowHeightTotal += new GridRowColSizeTotalEventHandler(Model_QueryRowHeightTotal); inModel_QueryRowHeight = true; } protected override void OnLoad(EventArgs e) { base.OnLoad (e); this.gridDataBoundGrid1.Model.RowHeights.ResizeToFit(this.gridDataBoundGrid1.ViewLayout.VisibleCellsRange, GridResizeToFitOptions.IncludeCellsWithinCoveredRange); inModel_QueryRowHeight = false; } bool inModel_QueryRowHeight = false; void Model_QueryRowHeightTotal(object sender, GridRowColSizeTotalEventArgs e) { GridModel gridModel = (GridModel)sender; ResizeRows(gridModel, e.From, e.Last); } void Model_QueryRowHeight(object sender, GridRowColSizeEventArgs e) { GridModel gridModel = (GridModel)sender; ResizeRows(gridModel, e.Index, e.Index); } void ResizeRows(GridModel gridModel, int from, int to) { if (inModel_QueryRowHeight) return; inModel_QueryRowHeight = true; try { gridModel.RowHeights.ResizeToFit(GridRangeInfo.Rows(from, to), GridResizeToFitOptions.IncludeCellsWithinCoveredRange); } finally { inModel_QueryRowHeight = false; } } This is the example: ResizeRowsOnDemand.zip Stefan


MA manohar September 29, 2005 01:11 PM UTC

Hi Stefan, First let me thank in the progress.But I have couple of questions still. 1.)If I want to do ondemand,when will this "Model_QueryRowHeightTotal" or the other event(s) will get fired.What i mean is what is the operation I need to perform to fire this event. 2.)Second is,I would like to resize all the rows before I load the form(not on demand),in that case is there any other solution which i can opt for and reduce the load time(16 seconds). To make this requirement more clear I am providing you an attachment with some images. First image contains only one row.when i double click that row it will open the second image/form which contains 160 records with huge rich text in the second column(to open this it is taking 16 seconds). Thanks in advance, Regards, Manohar B. RichTextRows_4440.zip


AD Administrator Syncfusion Team September 29, 2005 03:58 PM UTC

Hi, 1) the grid will fire the event before the rows are drawn. The event will be fired just before the row comes into view when the user is scrolling through the grid. 2) I don''t know of any way to make the RichText cell resize faster. It is a very slow operation to resize a rich text box since you probably need to initialize a RichTextBox cell by cell and let it resize itsself using some tricks. I am actually not aware that the grid has code for resizing RichText cells... The GridRichTextBoxCellModel does not implement CalculatePreferredCellSize. Did you provide your own implementaion here? Stefan >Hi Stefan, > > First let me thank in the progress.But I have couple of questions still. > >1.)If I want to do ondemand,when will this "Model_QueryRowHeightTotal" or the other event(s) will get fired.What i mean is what is the operation I need to perform to fire this event. >2.)Second is,I would like to resize all the rows before I load the form(not on demand),in that case is there any other solution which i can opt for and reduce the load time(16 seconds). > >To make this requirement more clear I am providing you an attachment with some images. >First image contains only one row.when i double click that row it will open the second image/form which contains 160 records with huge rich text in the second column(to open this it is taking 16 seconds). > >Thanks in advance, > >Regards, >Manohar B. > >RichTextRows_4440.zip > >


MA manohar September 30, 2005 07:33 AM UTC

Hi Stefan, The attahcment(ResizeRowsOnDemand_ca7c2aff.zip) you have sent has got one bug, its not getting excuted.I am providing the error message,pls rectify it and send me back as early as possible. Regards, Manohar B. Error_5133.zip


AD Administrator Syncfusion Team October 3, 2005 12:46 AM UTC

Hi, The data file was missing and I did not check in the sample if record count equals 0. Please copy the following files to the directory and also change the following line in the sample: ReadXml(@"GDBDdata.XML"); // used to be Data/GDBDdata GDBDdata.zip Stefan


HI Hijacker January 20, 2012 08:00 PM UTC

Syncfusion developers / staff,

I would like to congratulate you about the broken attachment links.
That's GREAT for us who seek a little help when dealing with problems on your amazingly slow WinForm grid control.

Your forum is also a great for code display and understanding. As we can see it's almost impossible to understand what's going on between the conversations.

CONGRATULATIONS!!!!



RB Ragamathulla B Syncfusion Team January 26, 2012 05:58 AM UTC

Hi H1J4CK3R,

We regret for the inconvenience.

We have moved to the previous sample from the server due to server maintaince. I would like to suggest you please refer to the following samples for improve the performance which is holding in our sample broswer.

{Installed path}\Syncfusion\EssentialStudio\{Version}\Windows\Grid.Windows\Samples\2.0\Performance

Hope this helpful for your reference

http://help.syncfusion.com/ug_94/User%20Interface/Windows%20Forms/Grid/Documents/4341performance.htm

Let me know if you have any further concerns.

Regards,
Ragamathullah B.


Loader.
Live Chat Icon For mobile
Up arrow icon