471,604 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Manipulating a datagrid?

I'm using Visual Studio .NET 2003 (using C#).

On a form I have a datagrid where I've set the DataSource and
DataMember to receive values
from a view in a SQL 2000 database. It works fine.

However, I do want to change individual column's width.

Now I'v defined DataGridTableStyle Collection for each column, and I've
DataGridColumnStyle Collection for each DataGridTableStyle.

I've set the respective widths but at run time it gives the default
width (preferredColumnWidth)
for each column.

Do I need to produce any code to manipulate the settings I've done?

I have like (for the first column):

dtgtsFirstCol //DataGridTableStyle


dttbFirstCol //DataGridColumnStyle

Anybody that could guide me on this?


Dec 7 '05 #1
2 1539

I solved the problem. It's all a matter of investigating the property

I set the preferredColumnWidth to 150

and the RowheaderWidth to 0

However, grid refused to accept any smaller width than 15, but I got
the desired result.


Dec 7 '05 #2

I finally solved the mystery by setting the column widths.

Here is what I did:

I made a view with data from three tables and put it on the server in a
SQL database.

Then in my application on the form containing the datagrid I did the

Choose -> TableStyles. Add a member and give it a name.

Make sure you set the RowHeadersVisible to false
(this will make the default column of the grid invisible),
if you don't want to
have the default column of the grid to show.

Set the MappingName to the view (in this case) and click the
(Colloection) field and the ... button.

Now add as many columns that you need to show in the grid.

Give them unique names and HeaderText titles. Set the MappingName and
the width.

Click OK, OK and run the application.

And all I did was reading the help file a little and Voila!

Happy programming.


Dec 7 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by David Tilman | last post: by
2 posts views Thread by Daniel Kaseman | last post: by
2 posts views Thread by Maarten | last post: by
reply views Thread by Maarten | last post: by
2 posts views Thread by michael sorens | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.