Solved

DataGrid styling problems

Posted on 2003-11-17
5
397 Views
Last Modified: 2010-04-16
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.GridColumnStyles.Add(menuIDColumn);
                  tableStyle.GridColumnStyles.Add(nameColumn);
                  tableStyle.GridColumnStyles.Add(priceColumn);

                  tableStyle.AlternatingBackColor = System.Drawing.Color.WhiteSmoke;


                  orderDataGrid.TableStyles.Add(tableStyle);
}

This function is called in the form's constructor, along with row names and data types.

Thanks in advance.
0
Comment
Question by:_WolfyUK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Tonylmiller
ID: 9767664
It would be a good start to tell us what the problem is. . .

So what is it not doing correctly?  Is it doing some of the formatting, but not all?
0
 

Author Comment

by:_WolfyUK
ID: 9769609
It's not applying any formatting.
0
 
LVL 4

Accepted Solution

by:
Tonylmiller earned 75 total points
ID: 9770688
Are you sure your data table name is "Order"?
You didn't include your databinding statement, so I can't tell for sure.
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9771515
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.
0
 

Author Comment

by:_WolfyUK
ID: 9772466
d'oh!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question