Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I change height of header row of a datagrid 1

Status
Not open for further replies.

dougconran

Technical User
Sep 26, 2003
89
GB
How can I change the height of just the header row of a datagrid to accomodate 2 lines of header text?

Also, is it possible to hide the grey 'edit' bar at the left hand side of the datagrid (the grid is set to readonly)?

TIA

Doug
 
I hate datagrids.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
there is all kinds of stuff on that site if you go to the root url. webforms, winforms controls, etc.

datagrids could be SOOOOOOO much better (and supposedly are in 2k5).


glad i could help.

hayt
 
I've just tried the example given and, although it works fine for the rows in the body of the datagrid it doesn't give a way of changing the header row (that I can see).

The reason I need to change the row height is because some of the column titles wrap onto a second line and are lost with the standard height.

I don't want to change the height of all rows just to accomodate a long header but I'm a bit stuck at the moment.

I struggle with understanding VB.NET at the best of times and, although I've had a look at the code in the example, I don't really understand it and certainly can't fathom out how to modify it.

Any help would be much appreciated (or any alternative suggestions on how to deal with multi-line headings).

TIA

Doug
 
You can change the size of the HeaderFont. Here is an example that has worked for me. It does not change the actual size of the text, just the header row height.

Code:
DataGrid1.HeaderFont = New Font("Verdana", 16, FontStyle.Regular, GraphicsUnit.Point)
 
I'm not sure if there is a way to do that with the MS data grid. I just tried flipping through the controls collection, figured that would be the most likely way to track down the properties you need, but the controls only contain the text boxes for fields, not the headers.

-Rick

----------------------
 
sorry that i didn't notice the word header. i've been searching all around trying to find some info for you, haven't found anything. but just because i am curious...changing the width doesn't help? or is the column too long with the data too short?


hayt
 
[bigsmile] SUCCESS! (after a fashion).

Many thanks to andrea96 - your solution worked with a minor exception, which is that I couldn't get bold, event by changing the fontstyle.

I think the reason is that I am using a TableStyle (sheet?) for other reasons, to be able to colour individual cells. When I tried andrea96's solution on the TableStyle I got no joy, the header just stayed the sime size. When I applied it to the Datagrid it worked fine but I couldn't change the font or fontstyle.

HOWEVER -- when I then added my original TableStyle command immediately afterwards it worked.

What I now have is:-

Code:
        Dim tableStyle As DataGridTableStyle
        tableStyle = New DataGridTableStyle
        tableStyle.HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
        DataGrid1.HeaderFont = New Font("Verdana", 16, FontStyle.Regular, GraphicsUnit.Point)
        tableStyle.MappingName = "dates"

Thanks for everyone's help and suggestions

Doug
 
Another helpfull tip

me and thatrickguy always advise the use of componentones flexgrid wich is free if you download the vb.net resourcekit.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks - am downloading right now - see you tomorrow (I have an ISDN line :(

Doug
 
oh BTW if you don't have a webserver installed be sure to uncheck the asp.net components else it will give you an error and will stop installing somewhere halfway in the install, and you will get nervous because it doesn't want to install and get all worked up and end up in the street because you insulted your boss and get killed by a passing bus.

just to say you'd better watch out what you do.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
I've avoided the buses (so far), the installation automatically installed the Cassini Personal Web server and I have IIS also installed.

But - how do I actually get at the flexgrid (and anything else) from within my App? In VB6 I had to install additonal components, do I do something similar here?

TIA

Doug
 
yep,

when in design mode go to the toolbox right click and select add and remove items then select the c1 components you want.

BTW after installing the resource kit you neede to install the c1 components. And then they should be in the list of add and remove items.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top