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);
}
 
When you assign the DataSource, does the table have a name of "Table3" ?
 
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
 
I take back my first reply, it works perfectly now. Thanks for the help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top