Custom DataGridTextBoxColumn

  • Thread starter Thread starter Pietje de kort
  • Start date Start date
P

Pietje de kort

Hello all,

currently I am building a customized DataGridTextBoxColumn class.
I wish to override the GetMinimumHeight() method. I think this method
is being called by the DataGrid for each cell in the grid.

What I ofcourse want is to resize the height of rows according to
their
content. When the content has newlines the height should increase, so
all lines are visible in the grid.

I am able to do some resizing, it is pretty hairy though. I can't
figure out
in which order the GetMinimumHeight is called. More specifically;
I am calling GetColumnValueAtRow to determine which item to get the
height from, it does return values. But I have to take care of the
rowIndex myself, and this doesn't work correctly (the rowIndex
parameter in
the code below.)

What I need is a way for the baseclasses to determine which row is
being requested, maybe there is someone from Microsoft that can help
with a
way to override the GetMinumumHeight method?

protected override int GetMinimumHeight()
{
CurrencyManager cur = (CurrencyManager)
DataGridTableStyle.DataGrid.BindingContext
[DataGridTableStyle.DataGrid.DataSource];
string s = GetColumnValueAtRow(cur,rowIndex).ToString();
return CalcStringHeight(s);
}
 
Pietje,

The idea for the data grid is that you can not have variable-height
rows. The minimum height is the minimum height needed to display ^ANY^ row
in the data grid. Because of that, you will need to cycle through all the
rows and figure out how much space you need for the largest content in the
table, and then return that.

Hope this helps.
 
Because of that, you will need to cycle through all the
rows and figure out how much space you need for the largest content in the
table, and then return that.

Ok, I know, but the GetMinimumHeight method is called for a specific datarow.
In fact, it gets called for the same datarow a few times (2 or 3). If I am
able to figure out which rowindex it's being called for, I can determine
the height for a specific value.
I have already done so, but I am unable to figure out which row the method
is being called for. It doesnt seem to have a specific structure.

Do you know the structure?
 
Back
Top