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

RowHeights.ResizeToFit()

Thread ID:

Created:

Updated:

Platform:

Replies:

53740 Dec 19,2006 06:16 PM UTC Dec 22,2006 12:11 PM UTC Windows Forms 9
loading
Tags: GridControl
Christian Pogea
Asked On December 19, 2006 06:16 PM UTC

i am using syncfusion 3.201.1.0 and need an advice how to use rowHeights.ResizeToFit on the GridDataBoundGrid. i can't move to 4.4 because there are still issues that affects me very badly.

i tried to use RowHeights.ResizeToFit() after populating the data to the table. if the user chances the sorting, i had to fire it again...
also if the data gets updated...

so i tried to use it on prepareviewstlyinfo and it seems to work very well, if i use GridRangeInfo.Row(e.RowIndex). but if you change the sorting, sometimes the grid didn't paint some rows. if you click on the cell, it will be painted... i have attached 2 screenshots.

on the first you can see, the refresh problem on the 2nd you can see what happen if you click on the invisible cell.

i really can't move to syncfusion 4.4. i eighter need a workaround or a better way to use RowHeights.ResizeToFit.

that's how my prepareviewstyleinfo looks like:

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
gridDataBoundGrid1.Model.RowHeights.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Row(e.RowIndex),GridResizeToFitOptions.None);

if(e.RowIndex > 0)
{
try
{
int schweregrad = (int)dv[e.RowIndex - 1]["Schweregrad"];

if (schweregrad > 7)
e.Style.BackColor = Color.Red;
else if (schweregrad > 3)
e.Style.BackColor = Color.Yellow;
else
e.Style.BackColor = Color.Green;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
}


events1.zip

Administrator [Syncfusion]
Replied On December 20, 2006 04:36 AM UTC

Hi Christian,

You can handle the Binder.BindingListChanged event and call the RowHeights.ResizeToFit method to resize the table in a grid. Here is a code snippet to show this.

private void Binder_BindingListChanged(object sender, ListChangedEventArgs e)
{
this.gridDataBoundGrid1.Model.RowHeights.ResizeToFit(GridRangeInfo.Table());

}

Please refer to the attached sample for implementation.
GDBGResizeToFit.zip

Best Regards,
Haneef

Christian Pogea
Replied On December 20, 2006 11:05 AM UTC

thank you very much for the sample. i couldn't test it, because i don't have XlsIO installed. i tried to fire resizetofit at CurrentCellChanged and BindingListChanged but it won't fire, if i change the sorting.

could you send me a sample, without XLSIO that handles the sorting change, please.

Administrator [Syncfusion]
Replied On December 20, 2006 11:27 AM UTC

Hi Christian,

You would have to derive the GridDataBoundGrid control and override the SortColumn method to resize the rows in a GridDataBoundGrid. Here is a code snippet.

public class MyDataBoundGrid: GridDataBoundGrid
{
public MyDataBoundGrid():base(){}
public override void SortColumn(int colIndex)
{
base.SortColumn (colIndex);
//Resize all rows in a grid.
Model.RowHeights.ResizeToFit(GridRangeInfo.Table());
}
}

Please refer to the modified sample for implementation.
GDBGResizeToFit_9c7d97bc.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On December 20, 2006 01:33 PM UTC

hi,

thank you for the fast response. unfortunately, i think you didn't test it, before you send it to me. i changed it a litte bit to show you, it didn't work properly.

at the parentid 3 there is a large text. please start the app. and sort by parentid. after a double click on parentid you can see the row is higher than the others. but if you double click on parentid the 2nd time, this row is still higher than the others, but there is only a small text.

GDBGResizeToFit_changed.zip

Administrator [Syncfusion]
Replied On December 21, 2006 04:30 AM UTC

Hi Christian,

Thanks for your update.

One way you can resolve this issue by calling Refresh() method to repaint the grid in SortColumn override method. Here is a code snippet to show this.

public class MyDataBoundGrid: GridDataBoundGrid
{
public MyDataBoundGrid():base(){}

public override void SortColumn(int colIndex)
{
base.SortColumn (colIndex);
Model.BeginUpdate();
Model.RowHeights.ResizeToFit(GridRangeInfo.Table());
Model.EndUpdate(true);
Refresh();
}
}

Let me know if this helps.

Best Regards,
Haneef

Christian Pogea
Replied On December 21, 2006 11:50 AM UTC

thank you. that works much better, but if i add a new row by datatable.Rows.Add(), i got refresh problems, too and it won't fire RowHeights.ResizeToFit()

please start the app. sort by dobbleclick on parentid twice (so you can see parentid 11 on top. and then push the button1 5 times. the refresh doesn't work properly....

please come back with a working sample.



GDBGResizeToFit_changed0.zip

Administrator [Syncfusion]
Replied On December 21, 2006 12:31 PM UTC

Hi Christian,

You can handle the Binder.BindingListChanged event and call the ResizeToFit method to resize the gridtable when the new record was added. Here is a code snippet to show this

private void Binder_BindingListChanged(object sender, ListChangedEventArgs e)
{
if(e.ListChangedType == ListChangedType.ItemAdded)
{
Binder.EndEdit();
Model.BeginUpdate();
Model.RowHeights.ResizeToFit(GridRangeInfo.Table());
Model.EndUpdate(true);
Refresh();
}
}

Here is a modified sample.
GDBGResizeToFit_Modified.zip

Best Regards,
Haneef

Christian Pogea
Replied On December 21, 2006 04:33 PM UTC

that work better, but there are still refresh problems and i think the more rows there are, the slower it will be, because for every row you insert in the database it calculates the rowheights for the whole rows. maybe it will be smarter to store that information in the model or anywhere and resize the rows only if the data changes...

is there no easy way to turn on automatic rowheights or am i the first customer that need that feature???

i'll try to modify your sample to show you the refresh problems. please come back with a smart solution for my problem.

Administrator [Syncfusion]
Replied On December 22, 2006 12:11 PM UTC

Hi Christian,

Please try the attached sample and let me know if you are looking different.
GDBGResizeToFit_changed.zip

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

;