datagridtablestyle

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have tried to modify the width of the columns in my dataset and nothing is
working. I used the designer to begin with and it didn't work so now I'm
calling it in the load event of the form. The DataTable shows up, but with
no modifications. The name of the DataTable is "Table3".

private void LineSelect_Load(object sender, System.EventArgs e)
{
this.LSDataGrid.DataSource = this.Order;

DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "Table3";

DataGridColumnStyle item = new DataGridTextBoxColumn();
item.MappingName = "Item No";
item.HeaderText = "Item No";
item.NullText = "";
item.Width = 50;
dgts.GridColumnStyles.Add(item);

DataGridColumnStyle qty = new DataGridTextBoxColumn();
qty.MappingName = "Qty To Pick";
qty.HeaderText = "Qty To Pick";
qty.NullText = "";
qty.Width = 50;
dgts.GridColumnStyles.Add(qty);

DataGridColumnStyle loc = new DataGridTextBoxColumn();
loc.MappingName = "Location 1";
loc.HeaderText = "Location 1";
loc.NullText = "";
loc.Width = 50;
dgts.GridColumnStyles.Add(loc);

this.LSDataGrid.TableStyles.Add(dgts);
}
 
Yes, the name is defaulted from a sql server and I've tested it using:
MessageBox.Show(Order.TableName.ToString());
 
Yes, I tested with: MessageBox.Show(Order.TableName.ToString()); to make sure
it was the same name.
 
LMIT,

please try a

LSDataGrid.TableStyles.Clear()

before calling :
this.LSDataGrid.TableStyles.Add(dgts);

HTH
Ruediger
 
Back
Top