HighTechTalks DotNet Forums  

DataGrid Column Widths

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss DataGrid Column Widths in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Grimmthething
 
Posts: n/a

Default DataGrid Column Widths - 11-05-2004 , 11:03 PM






I am having trouble setting my column widths at run-time. I realize i
must make a Table Style, and a Column Style, it compiles, but the
datagrid column never changes. I even tried adding one at compile-time,
(that didnt' work) and taking .Nets code directly and applying it at
run-time, which also didn't work. Here is my code, any ideas? (dgd is
the dataGrid, and "Description" is the column name i was trying to
set).

DataGridTableStyle dataGridTableStyle1;
DataGridTextBoxColumn dataGridTextBoxColumn1;
dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();
//
// dataGridTableStyle1
//
dataGridTableStyle1.set_DataGrid(dgd);
dataGridTableStyle1.get_GridColumnStyles().AddRang e(new
DataGridColumnStyle[]
{
dataGridTextBoxColumn1}
);
dataGridTableStyle1.set_HeaderForeColor(System.Dra wing.SystemColors.get_ControlText());
dataGridTableStyle1.set_MappingName("");
//
// dataGridTextBoxColumn1
//
dataGridTextBoxColumn1.set_Format("");
dataGridTextBoxColumn1.set_FormatInfo(null);
dataGridTextBoxColumn1.set_MappingName("Descriptio n");
dataGridTextBoxColumn1.set_Width(50);


Reply With Quote
  #2  
Old   
Grimmthething
 
Posts: n/a

Default Re: DataGrid Column Widths - 11-07-2004 , 12:29 PM






Thanks Lars,

I believe what my problem was is i used the wrong mapping name, as
you suggested. I am dynamically setting the datasets to their
corresponding tables, and i am not setting the table name, so they all
end up being "table" or something like that. It works now..
I didn't realize until now that is if you set a table style you
have to add all the columns, if i change one column, that will be the
only one that shows up on the datagrid, i have to add table styles to
the rest of them also. Not a problem since i am going to add styles to
them all. Thank you very much for your help, you solved a problem
that i spent way too many hours on.
-Grimm

BTW: i am sending you an email


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.