473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Custom DataGridTextBoxColumn

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);
}
Nov 15 '05 #1
2 3837
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pietje de kort" <wo******@hotmail.com> wrote in message
news:e0**************************@posting.google.c om...
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);
}

Nov 15 '05 #2
> 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?
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
I have created a custom DataGrid control which implements a custom property HighlightRow of type Boolean. I have another custom DataGridTextBoxColumn class, which Overrides the Paint method in...
1
by: Saso Zagoranski | last post by:
Hi! I have extended the default windows.forms datagrid... I added a few options if the data is bound programmaticly... The main part of the function (the for loop) loops through all the columns...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
3
by: Darryn Ross | last post by:
Hi, I am having a few problems with my datagrid, the data in my database isn't coming through right. for example 100.00 in the table is coming through as 100 and 01/01/2004 in the table is...
1
by: Vagabond Software | last post by:
I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form,...
1
by: Darryn Ross | last post by:
Hi, I am trying to display a long integer value from my access table in a Datagrid with a custom style applied to it and the value is not coming through correct?? database value = 0.00000 %...
2
by: Wayne Gibson | last post by:
Hi, I'm using the DataGridViewTextBoxColumn and I'm trying to find a way to detect when the a key is pressed whilst it is being edited. But there doesn't appear to be any events for this.. So...
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
1
by: Will | last post by:
Hello, I wrote a custom object that Inherits from CollectionBase. This would, my object fits in a datagrid. However, my object (_obj) contains data and references I do NOT want the datagrid...
6
by: Bob The Builder | last post by:
I have a custom-built datagrid for windows forms. I overrode the scrollbars in it because I wanted to draw my own (basically, they're skinned). As a result, I handle all scroll events and calls. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.