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