_WolfyUK
asked on
DataGrid styling problems
Hello,
I'm going mad trying to figure out why my DataGrid is not being formatted as I want it to be. I have three columns which I style using a single DataGridTableStyle with DataGridTextBoxColumns for each column's style.
The styling is called from the function AddColumns(), below:
private void AddColumns()
{
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Order";
DataGridTextBoxColumn menuIDColumn = new DataGridTextBoxColumn();
menuIDColumn.MappingName = "ItemMenuID";
menuIDColumn.HeaderText = "Menu ID";
menuIDColumn.Alignment= HorizontalAlignment.Left;
menuIDColumn.Width = 10;
menuIDColumn.NullText = "";
DataGridTextBoxColumn nameColumn = new DataGridTextBoxColumn();
nameColumn.MappingName = "ItemName";
nameColumn.HeaderText = "Name";
nameColumn.Alignment = HorizontalAlignment.Left;
nameColumn.Width = 200;
nameColumn.NullText = "";
DataGridTextBoxColumn priceColumn = new DataGridTextBoxColumn();
priceColumn.MappingName = "ItemPrice";
priceColumn.HeaderText = "Price";
priceColumn.Alignment = HorizontalAlignment.Left;
priceColumn.Width = 20;
priceColumn.NullText = "";
tableStyle.GridColumnStyle s.Add(menu IDColumn);
tableStyle.GridColumnStyle s.Add(name Column);
tableStyle.GridColumnStyle s.Add(pric eColumn);
tableStyle.AlternatingBack Color = System.Drawing.Color.White Smoke;
orderDataGrid.TableStyles. Add(tableS tyle);
}
This function is called in the form's constructor, along with row names and data types.
Thanks in advance.
I'm going mad trying to figure out why my DataGrid is not being formatted as I want it to be. I have three columns which I style using a single DataGridTableStyle with DataGridTextBoxColumns for each column's style.
The styling is called from the function AddColumns(), below:
private void AddColumns()
{
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Order";
DataGridTextBoxColumn menuIDColumn = new DataGridTextBoxColumn();
menuIDColumn.MappingName = "ItemMenuID";
menuIDColumn.HeaderText = "Menu ID";
menuIDColumn.Alignment= HorizontalAlignment.Left;
menuIDColumn.Width = 10;
menuIDColumn.NullText = "";
DataGridTextBoxColumn nameColumn = new DataGridTextBoxColumn();
nameColumn.MappingName = "ItemName";
nameColumn.HeaderText = "Name";
nameColumn.Alignment = HorizontalAlignment.Left;
nameColumn.Width = 200;
nameColumn.NullText = "";
DataGridTextBoxColumn priceColumn = new DataGridTextBoxColumn();
priceColumn.MappingName = "ItemPrice";
priceColumn.HeaderText = "Price";
priceColumn.Alignment = HorizontalAlignment.Left;
priceColumn.Width = 20;
priceColumn.NullText = "";
tableStyle.GridColumnStyle
tableStyle.GridColumnStyle
tableStyle.GridColumnStyle
tableStyle.AlternatingBack
orderDataGrid.TableStyles.
}
This function is called in the form's constructor, along with row names and data types.
Thanks in advance.
ASKER
It's not applying any formatting.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What are you binding to?
Are you pulling this data from say a SQL DB.
If so you need to do the binding.
And you may be doing things out of order.
Are you pulling this data from say a SQL DB.
If so you need to do the binding.
And you may be doing things out of order.
ASKER
d'oh!
So what is it not doing correctly? Is it doing some of the formatting, but not all?