Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DataGrid styling problems

Posted on 2003-11-17
5
Medium Priority
?
399 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 300 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

670 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