how do i change the column width of one column in the datagrid? 
Author Message
 how do i change the column width of one column in the datagrid?

I saw a demo of this somewhere and now I can't find it.

Paul



Mon, 31 Jan 2005 20:38:01 GMT  
 how do i change the column width of one column in the datagrid?
Hi Paul
If this is a windows.forms datagrid then you can use a DataGridTableStyle
and add DataGridColumnStyles for each column. The DataGridColumnStyles have
a Width property that allows you to control the size of the column.
If you don't specify a TableStyle, then the DataGrid will create one for
you. You can get the columnstyles collection with code like this
myGrid.TableStyles(0).GridColumnStyles and then set the width of the one you
require.

Hope that helps a little
J.

Jasmine
www.datagridcolumnstyles.net
Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid


Quote:
> I saw a demo of this somewhere and now I can't find it.

> Paul



Mon, 31 Jan 2005 21:06:13 GMT  
 how do i change the column width of one column in the datagrid?
Jasmine,
I managed to get this to work by assigning a new DataGridTableStyle
to the to the grid. However I dont think the datagrid creates one by default
if you do not assign one. If I try to
myGrid.TableStyles(0).GridColumnStyles(0).width = 200 without assigning a
tablstyles first is gives me an exception error of index out of range. I
really just wanted to change the column width in the grid and have all the
style and appearnace settings of the grid stay the same. If I assign a
DatagridTableStyle I lose all the appearance of the grid.



Quote:
> Hi Paul
> If this is a windows.forms datagrid then you can use a DataGridTableStyle
> and add DataGridColumnStyles for each column. The DataGridColumnStyles
have
> a Width property that allows you to control the size of the column.
> If you don't specify a TableStyle, then the DataGrid will create one for
> you. You can get the columnstyles collection with code like this
> myGrid.TableStyles(0).GridColumnStyles and then set the width of the one
you
> require.

> Hope that helps a little
> J.

> Jasmine
> www.datagridcolumnstyles.net
> Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid



> > I saw a demo of this somewhere and now I can't find it.

> > Paul



Tue, 01 Feb 2005 03:30:04 GMT  
 how do i change the column width of one column in the datagrid?
Hi Paul
I so sorry, I was thinking of the DataGrid.defaultTableStyle property which
is, sadly, private when I was talking about the one the datagrid creates
automatically. I had another thought that might help you, but it involves
using methods that are marked '.Net Infrastructure and not to be used'. In
the end it didn't work anyway but it would be nice to have access to the
DefaultTableStyle.

sorry again, I guess you might be stuck with using a TableStyle

J.

Jasmine
www.datagridcolumnstyles.net
Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid


Quote:
> Jasmine,
> I managed to get this to work by assigning a new DataGridTableStyle
> to the to the grid. However I dont think the datagrid creates one by
default
> if you do not assign one. If I try to
> myGrid.TableStyles(0).GridColumnStyles(0).width = 200 without assigning a
> tablstyles first is gives me an exception error of index out of range. I
> really just wanted to change the column width in the grid and have all the
> style and appearnace settings of the grid stay the same. If I assign a
> DatagridTableStyle I lose all the appearance of the grid.



> > Hi Paul
> > If this is a windows.forms datagrid then you can use a
DataGridTableStyle
> > and add DataGridColumnStyles for each column. The DataGridColumnStyles
> have
> > a Width property that allows you to control the size of the column.
> > If you don't specify a TableStyle, then the DataGrid will create one for
> > you. You can get the columnstyles collection with code like this
> > myGrid.TableStyles(0).GridColumnStyles and then set the width of the one
> you
> > require.

> > Hope that helps a little
> > J.

> > Jasmine
> > www.datagridcolumnstyles.net
> > Custom DataGridColumnStyles for the Microsoft .Net Windows Forms
DataGrid



> > > I saw a demo of this somewhere and now I can't find it.

> > > Paul



Tue, 01 Feb 2005 04:19:16 GMT  
 how do i change the column width of one column in the datagrid?
Jasmine, dont know if this requires starting new thread or not but I was
wondering about the Tablestyles Collection option that is available in
Visual Studio .NET in the grid properties window. How can you use this? I
tried to set some stuff up under this but could not figure out how to use
it? It comes back around to my orginal problem. There seems to be more
properties available to me in the properies window of the grid then are
available when setting the properies in code vai the Tablestyle object?

Any clues
Paul



Quote:
> Hi Paul
> I so sorry, I was thinking of the DataGrid.defaultTableStyle property
which
> is, sadly, private when I was talking about the one the datagrid creates
> automatically. I had another thought that might help you, but it involves
> using methods that are marked '.Net Infrastructure and not to be used'. In
> the end it didn't work anyway but it would be nice to have access to the
> DefaultTableStyle.

> sorry again, I guess you might be stuck with using a TableStyle

> J.

> Jasmine
> www.datagridcolumnstyles.net
> Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid



> > Jasmine,
> > I managed to get this to work by assigning a new DataGridTableStyle
> > to the to the grid. However I dont think the datagrid creates one by
> default
> > if you do not assign one. If I try to
> > myGrid.TableStyles(0).GridColumnStyles(0).width = 200 without assigning
a
> > tablstyles first is gives me an exception error of index out of range. I
> > really just wanted to change the column width in the grid and have all
the
> > style and appearnace settings of the grid stay the same. If I assign a
> > DatagridTableStyle I lose all the appearance of the grid.



> > > Hi Paul
> > > If this is a windows.forms datagrid then you can use a
> DataGridTableStyle
> > > and add DataGridColumnStyles for each column. The DataGridColumnStyles
> > have
> > > a Width property that allows you to control the size of the column.
> > > If you don't specify a TableStyle, then the DataGrid will create one
for
> > > you. You can get the columnstyles collection with code like this
> > > myGrid.TableStyles(0).GridColumnStyles and then set the width of the
one
> > you
> > > require.

> > > Hope that helps a little
> > > J.

> > > Jasmine
> > > www.datagridcolumnstyles.net
> > > Custom DataGridColumnStyles for the Microsoft .Net Windows Forms
> DataGrid



> > > > I saw a demo of this somewhere and now I can't find it.

> > > > Paul



Tue, 01 Feb 2005 20:34:11 GMT  
 how do i change the column width of one column in the datagrid?
Hi Paul,
The good thing about starting a new thread is that it's easier to get other
peoples opinion on the matter.
On the other hand, despite my faux pas about the defaultTableStyle I'm not
too bad with the TableStyles things, you just caught me right in the middle
of being stupid ;-)

There are lots of properties in the grid that also appear in the TableStyles
properties - this can cause some problems as it's not obvious what matching
properties take precedence. The properties from the grid allow you to set
styling for the grid without regard to the data that you are displaying, so
if you had a dataset with three tables, the 'style'(colors fonts etc) of the
grid would remain the same no matter which table you were displaying.
When you use a TableStyle you specifically link 'styling' to an individual
DataTable by using the TableStyle mapping name, so you might table1 to have
green rows, table two to be readonly and table three to be candy striped and
not allow sorting. This is even clearer when you have relationships in your
data (when you get the little expander + sign), it allows to differentiate
the data in the relations visually and also to control attributes like
readonly and sorting abilities based on the data you are displaying. Without
using TableStyles all the different tables you display look and act the
same.
One effect of using TablesStyles is that you must define ColumnStyles for
each column you want to show, this might seem a little tiresome but actually
it provides you with a lot of control over the layout of your data, you can
reorder the position of columns, completely hide columns you don't want to
show, give them a more descriptive column header if you like and control the
readonly attributes on a column by column basis. It is also the only proper
way to show custom columnstyles, so if you want to display an image or a
dropdown list or some other control you need to use TableStyles and assign
columnstyles to each column. I say 'proper' here because you can do the old
trick of just making a control appear over the grid to effect a control in
the cell.
To see the effects of using custom columnstyles compared with a normal
'unstyled' grid see www.datagridcolumnstyles.net/compare.asp (I'm not trying
to sell you anything here - just showing you what can be achieved with
TableStyles and ColumnStyles).

The key thing to remember is to get the TableStyle mapping name correct. If
that's not right the TableStyle doesn't get applied and the grid defaults to
the standard grid properties. Likewise the mapping name of the ColumnStyles
must be correct or the columns will not appear in the grid.

Has that helped a little? If you've got a specific question feel free to
ask. I'll try to keep my brain switched on this time !
J.

Jasmine
www.datagridcolumnstyles.net
Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid


Quote:
> Jasmine, dont know if this requires starting new thread or not but I was
> wondering about the Tablestyles Collection option that is available in
> Visual Studio .NET in the grid properties window. How can you use this? I
> tried to set some stuff up under this but could not figure out how to use
> it? It comes back around to my orginal problem. There seems to be more
> properties available to me in the properies window of the grid then are
> available when setting the properies in code vai the Tablestyle object?

> Any clues
> Paul



> > Hi Paul
> > I so sorry, I was thinking of the DataGrid.defaultTableStyle property
> which
> > is, sadly, private when I was talking about the one the datagrid creates
> > automatically. I had another thought that might help you, but it
involves
> > using methods that are marked '.Net Infrastructure and not to be used'.
In
> > the end it didn't work anyway but it would be nice to have access to the
> > DefaultTableStyle.

> > sorry again, I guess you might be stuck with using a TableStyle

> > J.

> > Jasmine
> > www.datagridcolumnstyles.net
> > Custom DataGridColumnStyles for the Microsoft .Net Windows Forms
DataGrid



> > > Jasmine,
> > > I managed to get this to work by assigning a new DataGridTableStyle
> > > to the to the grid. However I dont think the datagrid creates one by
> > default
> > > if you do not assign one. If I try to
> > > myGrid.TableStyles(0).GridColumnStyles(0).width = 200 without
assigning
> a
> > > tablstyles first is gives me an exception error of index out of range.
I
> > > really just wanted to change the column width in the grid and have all
> the
> > > style and appearnace settings of the grid stay the same. If I assign a
> > > DatagridTableStyle I lose all the appearance of the grid.


in

> > > > Hi Paul
> > > > If this is a windows.forms datagrid then you can use a
> > DataGridTableStyle
> > > > and add DataGridColumnStyles for each column. The

DataGridColumnStyles

- Show quoted text -

Quote:
> > > have
> > > > a Width property that allows you to control the size of the column.
> > > > If you don't specify a TableStyle, then the DataGrid will create one
> for
> > > > you. You can get the columnstyles collection with code like this
> > > > myGrid.TableStyles(0).GridColumnStyles and then set the width of the
> one
> > > you
> > > > require.

> > > > Hope that helps a little
> > > > J.

> > > > Jasmine
> > > > www.datagridcolumnstyles.net
> > > > Custom DataGridColumnStyles for the Microsoft .Net Windows Forms
> > DataGrid



> > > > > I saw a demo of this somewhere and now I can't find it.

> > > > > Paul



Tue, 01 Feb 2005 21:13:14 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. setting width on one column in a datagrid

2. How to change width of DataGrid columns

3. how change in DataGrid (column Width and header)

4. DataGrids: handling KeyDown and changing column widths

5. change the column width of DataGrid

6. how to change the width of a column i a datagrid

7. Setting datagrid column width sets width of toplevel!!

8. Error creating rows with columns having different column width

9. Multi Column TextBox Column Widths

10. datagrid column width on webform

11. DataGrid Setting Width of Columns to Fit Autofit.

12. DataGrid Control Column Width

 

 
Powered by phpBB® Forum Software