Setting column width to datagrid doesn't work

  • Thread starter Thread starter ejsanchez
  • Start date Start date
E

ejsanchez

I'm using the following code to resize the column width of
my datagrid in the "Form_Load" method:

myDataGrid.TableStyles.Clear();
DataGridTableStyle dg1TabStyle=new DataGridTableStyle();
dg1TabStyle.MappingName="<table_name>";

DataGridTextBoxColumn col1=new DataGridTextBoxColumn();
col1.TextBox.Enabled=false;
col1.Alignment=HorizontalAlignment.Right;
col1.HeaderText="<Some Text>";
col1.MappingName="<table_col_name>";
col1.With=500;
dgTabStyle=GridColumnStyles.Add(col1);

myDataGrid.TableStyles.Add(sociosTableStyle);

This don't work :(
The columns in the Datagrid remain the same size, no change at all.
Any help or advice would be appreciated.
thanks in advance,

-eduardo s.m.
 
Hi,

I'm using the following code to resize the column width of
my datagrid in the "Form_Load" method:

myDataGrid.TableStyles.Clear();
DataGridTableStyle dg1TabStyle=new DataGridTableStyle();
dg1TabStyle.MappingName="<table_name>";

DataGridTextBoxColumn col1=new DataGridTextBoxColumn();
col1.TextBox.Enabled=false;
col1.Alignment=HorizontalAlignment.Right;
col1.HeaderText="<Some Text>";
col1.MappingName="<table_col_name>";
col1.With=500;
dgTabStyle=GridColumnStyles.Add(col1);

myDataGrid.TableStyles.Add(sociosTableStyle);

This don't work :(
The columns in the Datagrid remain the same size, no change at all.
Any help or advice would be appreciated.
thanks in advance,

If the other properties don't work either ( HeaderText, Alignment ) then
most likely the MappingName of the DataGridTableStyle is wrong, verify it by
checking the TableName property of the relevant table.

HTH,
Greetings
 
verify it by
checking the TableName property of the relevant table.

Thanks!, you were absolutely right, I was doing wrong the
mapping, setting the tablename solve my problems.

regards,
-eduardo s.m.
 
Back
Top