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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid formatting 1

Status
Not open for further replies.

hads

Technical User
Nov 12, 2001
257
AU
Hi guys,

Not sure if I am blind or just looking for something unpopular (doubt it) but I can't seem to find anywhere much info on how to format a datagrid.

The main thing I am looking for is how to set a column width to a fixed size rather than have it set itself to the width of the text. But I would also appreciate any nudges in the direction of general info on this.

Any ideas?

Cheers

hads
 
Do you create the columns at run time? Or do you declare them yourself?

If you select the columns yourself you can set the column width in the property builder : FORMAT - COLUMNS. (Don't forget to put of the option "Create columns automatically at run time" in the COLUMNS tab.)

You can create the columns in HTML. e.g.
<asp:BoundColumn DataField=&quot;column1&quot;></asp:BoundColumn>
 
Cheers for the reply,

Yeah the columns aren't generated automattically they are defined as bound columns and a hyperlink column.

If possible would you be able to post a bit of the HTML that defines the column widths as I'm not using Visual Studio yet and can't seem to find this partcular detail anywhere.(I figure I get a good knowledge of the actual code while I can't afford to buy it yet :)

Thanks,

hads.
 
Ok, I'll paste some HTML-code. I noticed you can set the width in HTML too, I used the property builder in Visual Studio to do it, but anyway :


<Columns>

<asp:ButtonColumn Text=&quot;Select&quot; CommandName=&quot;Select&quot;>
<HeaderStyle Wrap=&quot;False&quot; Width=&quot;10mm&quot;></HeaderStyle>
<ItemStyle Font-Size=&quot;XX-Small&quot; Font-Underline=&quot;True&quot; Font-Names=&quot;Verdana&quot; Wrap=&quot;False&quot; ForeColor=&quot;Blue&quot;></ItemStyle>
<FooterStyle Wrap=&quot;False&quot;></FooterStyle></asp:ButtonColumn>

<asp:BoundColumn DataField=&quot;column1&quot;><HeaderStyle Wrap =False Width=&quot;150mm&quot;></HeaderStyle></asp:BoundColumn>

</Columns>

As you can see I've pasted 2 different columns, 1 with a select button and 1 &quot;normal&quot; column. The part in bold is the most important one (for the column width...).

Greetz
 
Nice one.

Thanks heaps bud, thats exactly what I was after, it can be difficult to find things like that sometimes.

Cheers again,

hads.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top