Hi
Changing row height CalcRowHeight event handler of banded grid view at runtime seems to give unexpected result.
In banded gridview I want to increase the height of a row when user clicks within a rectangle area within that row. After making sure that the rectangle in question is clicked I call bandedGridView1.LayoutChanged() method on the banded gridview to fire the CalcRowHeight event of the banded gridview. Then I use following code in that event's event handler:
private void bandedGridView1_CalcRowHeight(object sender, RowHeightEventArgs e)
{
// check if the mouse click was within the 'sensitive' rectangle
if (isWithinBounds && rowToBeUpdated == e.RowHandle)
{
//change row height
e.RowHeight += 20;
// reset private variables
isWithinBounds = false;
rowToBeUpdated = -1;
}
}
When the app is run and the rectangle is clicked, the row height changes in the way shown in the attached JPG. The gap between the clicked row and the next one increases but the row itself doesn't seem to expand. It looks like the row height can be set when the grid is loading, but on runtime, it behaves different when row height is changed.
Can you guide me what to do to make the row itself to expand?
Regards
Okash
Hello Okash,
Which event do you use to call the LayoutChanged method? I advise that you call it from the FocusedRowChanged event when the row you what to make bigger gets focused.
If my suggestion doesn't help, please attach your test project - we'll try to find a solution. I also advise that you update your components to the most recent version - v8.2.6.
Thanks,
Nick
Hi Nick
I am calling LayoutChanged from the grid control's (container of the banded grid view) MouseDown event handler. Since the user might be in the same row and cell and then click the 'sensitive' rectangle area, calling LayoutChanged from FocusedRowChanged event won't be helpful.
I have attached the test project. The gridview has just one band and one column and because I have hard coded the row number for the purpose of testing, only the 2nd row is supposed to expand when clicked. The banded grid view's CustomDrawCell event handler just sets the 'sensitive' rectangle to the bounds of the cell in 2nd row.
If you have any questions regarding the code, do ask.
Thanks!
Okash
Hi Okash,
You shouldn't modify any other variable from within the CalcRowHeight event handler. This event can be fired multiple times during various grid calculations.
We recommend that you change the row height condition on every mouse click. Moreover, to determine if a point belongs to a cell rectangle, calculate the GridHitInfo object.
I have modified your project accordingly. It is attached. Please let us know if this makes sense.
Thanks,
Michael.
Hi Michael
Thanks for the updates project. That solves the problem!
Best regards
Okash
Hi Okash,
I am happy to hear that my assistance was helpful to you. Please do not hesitate to contact us if you experience problems when using our products. We will be happy to help you at any time.
Thanks,
Michael.