Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing width of DataGrid component

2 views
Skip to first unread message

glenn

unread,
Feb 12, 2005, 2:06:00 PM2/12/05
to
Can anyone tell me the easiest way to change the width of the colomns of a
datagrid. All the help files are telling me to set the PreferredColomnWidth
property but it does not seem to exist when I access the components
properties.

Can anyone tell me what I"m doing wrong that is making all the tutorials
provided with VS useless?

I'm using C#...

Thanks,

glenn


Sergey Bogdanov

unread,
Feb 12, 2005, 3:24:08 PM2/12/05
to

glenn

unread,
Feb 12, 2005, 5:54:50 PM2/12/05
to
I hope you are kidding., I have a grid with 20 fields in it and I have to
set the colomn width like this for each field? Is there no other way? This
is insane... :-) sorry, but 10 lines of code to set one fields width and
header is just insane to me...

Can you please confirm that there is no other way to accomplish this? Is
there another component out there that actually has been designed to work
that I can purchase? I don't mind buying something if it works.

thanks

glenn

"Sergey Bogdanov" <sergey....@gmail.com> wrote in message
news:uA45NDUE...@TK2MSFTNGP14.phx.gbl...

Sergey Bogdanov

unread,
Feb 13, 2005, 1:41:24 AM2/13/05
to
Actually only 5 :) ... and this sequence you may include into the
function and call as one line:


DataGridTableStyle dgts = new DataGridTableStyle();
void AddTBColumn(string fieldName, string header, int width)
{
DataGridColumnStyle c = new DataGridTextBoxColumn();
c.MappingName = fieldName;
c.HeaderText = header;
c.Width = width;
dgts.GridColumnStyles.Add(c);
}

...
dgts.MappingName = "TableName";

AddTBColumn("Field1", "Header1", 100);
AddTBColumn("Field2", "Header2", 100);
...
dataGrid1.TableStyles.Add(dgts);

Also you may consider SourceGrid:
http://www.devage.com/SourceGrid/SourceGrid2_EN.html

glenn

unread,
Feb 13, 2005, 10:21:32 AM2/13/05
to
Thanks, that is what I did as I couldn't find another way to handle it.
However, I'm having problems with getting the grid to show all my columns.
It goes across to 6 columns wide and then just stops. No errors or
anything. Is there a limit on how many fields you can add? Or on the
length of any one field?

Thanks,

glenn

"Sergey Bogdanov" <sergey....@gmail.com> wrote in message

news:ebSMJcZE...@TK2MSFTNGP10.phx.gbl...

glenn

unread,
Feb 13, 2005, 10:27:17 AM2/13/05
to
Nevermind, I figured it out...

Thanks for the help...

glenn


"glenn" <ghan...@softeksoftware.com> wrote in message
news:OKo38$dEFHA...@TK2MSFTNGP12.phx.gbl...

0 new messages