ussing CSS with a datagrid control

D

djc

I am in the middle of reading an article on the datagrid control from the
4guysfromrolla.com website. I already completed the part on formatting the
datagrid but it did not use any CSS for this. It did inform me of the
different 'styles' though:

HeaderSyle, FooterStyle, ItemStyle, and AlternatingItemStyle for the grid as
a whole and HeaderSyle, FooterStyle, ItemStyle, and DataFormatString for
specific columns. I have 2 specific question with regard to this.

1) can I simply assign a CssClass="cssClassID" to each of these datagrid
'styles' and do my formatting in my external style sheet?
2) I want to control the width of each individual column in my datagrid. I
don't mind if the rows get taller to accomodate more data but I don't want
my columns to get any wider or narrower. How should I go about doing that?

any input is greatly appreciated. Thanks.
 
J

Jos

djc said:
I am in the middle of reading an article on the datagrid control from
the 4guysfromrolla.com website. I already completed the part on
formatting the datagrid but it did not use any CSS for this. It did
inform me of the different 'styles' though:

HeaderSyle, FooterStyle, ItemStyle, and AlternatingItemStyle for the
grid as a whole and HeaderSyle, FooterStyle, ItemStyle, and
DataFormatString for specific columns. I have 2 specific question
with regard to this.

1) can I simply assign a CssClass="cssClassID" to each of these
datagrid 'styles' and do my formatting in my external style sheet?
Yes

2) I want to control the width of each individual column in my
datagrid. I don't mind if the rows get taller to accomodate more data
but I don't want my columns to get any wider or narrower. How should
I go about doing that?

Turn AutogenerateColumns off, and use BoundColumns (or TemplateColumns),
which have a Width property.
You can also set the width from code, like
"MyGrid.Columns(i).Width=whatever".

Additionally, in the ItemStyle, set Wrap="True".
 
D

djc

Thanks!

Jos said:
Turn AutogenerateColumns off, and use BoundColumns (or TemplateColumns),
which have a Width property.
You can also set the width from code, like
"MyGrid.Columns(i).Width=whatever".

Additionally, in the ItemStyle, set Wrap="True".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top