473,804 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't DataGridTableSt yle work?

I can't find what exactly I'm doing wrong that the following
DataGridTableSt yle is not working on my table. The result set returns
21 columns. I'm only formatting 5 via the TableStyle. I thought maybe
the problem was I had more columns being put into the DataGrid than I
was formatting. I then created a new table and adding only the five
mapped columns to it. That didn't help either.

I'm hiding column 3 because I need its value but don't want it
displayed. I do get the five columns output into the grid but no
styling. Any suggestions:

DataTable dt = new DataTable();

DataGridTableSt yle participantGrid TableStyle = new
DataGridTableSt yle();
participantGrid TableStyle.Mapp ingName = dt.TableName;

// Create GridColumnStyle objects for the grid columns
//First five columns are: PersonId, PersonCode, FirstName,
MiddleName, LastName

DataGridTextBox Column partCol1 = new DataGridTextBox Column();
DataGridTextBox Column partCol2 = new DataGridTextBox Column();
DataGridTextBox Column partCol3 = new DataGridTextBox Column();
DataGridTextBox Column partCol4 = new DataGridTextBox Column();
DataGridTextBox Column partCol5 = new DataGridTextBox Column();

partCol1.Mappin gName = "PersonId";
partCol2.Mappin gName = "PersonCode ";

//hide column 3
partCol3.Mappin gName = "FirstName" ;
partCol3.Width = 0;

partCol4.Mappin gName = "MiddleName ";

partCol5.Mappin gName = "LastName";
//just to see if style is outputting
partCol5.Header Text = "Last | Name";
partCol5.
partCol5.Width = 65;
partCol5.Alignm ent = HorizontalAlign ment.Left;
partCol5.TextBo x.Enabled = false;

// Add the GridColumnStyle s to the DataGrid's Column Styles
collection.
// Place the "ID" column (column 1) last since it is not visible.

participantGrid TableStyle.Grid ColumnStyles.Ad d(partCol1);
participantGrid TableStyle.Grid ColumnStyles.Ad d(partCol2);
participantGrid TableStyle.Grid ColumnStyles.Ad d(partCol3);
participantGrid TableStyle.Grid ColumnStyles.Ad d(partCol4);
participantGrid TableStyle.Grid ColumnStyles.Ad d(partCol5);

dt = (Searching.Find Participants()) .Tables[0];

//dt.TableName will now be "Table" because of above assignement.
dt.TableName = "ParticipantSea rch";

DataTable dtLimit = dt.Copy();;
//restrict to only five columns
int x = 5;
while (x < dtLimit.Columns .Count)
{
dtLimit.Columns .RemoveAt(x);
Debug.WriteLine (dt.Columns[x].ColumnName);
}

Participant.Tab leStyles.Clear( );
Participant.Tab leStyles.Add(pa rticipantGridTa bleStyle);

this.Participan t.DataSource = dtLimit;
Participant.Exp and(-1);
Participant.Nav igateTo(0, dt.TableName);

Thanks,
Brett

Dec 15 '05 #1
2 2427
Well I am not sure if this is it or not but....

You have this line:

participantGrid TableStyle.Mapp ingName = dt.TableName;

Then later on you have this line:

dt.TableName = "ParticipantSea rch";

Which means your DGTS is mapping to a table that doesn't really exist.

Try putting the MappingName assignment lower down.

Steven Nagy

Dec 15 '05 #2
Glad you posted back to this Steven. You are right. The problem was a
combination of what you mentioned and previously this line resetting
the table name.

dt = (Searching.Find Participants()) .Tables[0];

It reset the dt table back to "Table". That's why this line now
follows it.

dt.TableName = "ParticipantSea rch";

Thanks,
Brett

Dec 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3456
by: Carlos | last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a varibale lke DataGridTableStyle MyStyle = new DataGridTableStyle(); it give me "The Type or name sapce 'DataGridTableStyle 'could not be found" also I have the following at the begining of the program.. using System;
2
3132
by: Scott | last post by:
Hi all. A few days ago i ask this question and got a good quick response. I tried out what they said and it worked. However I have now come to try the same thing in another program and it does not seem to be working.
2
1769
by: Carlos | last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a varibale lke DataGridTableStyle MyStyle = new DataGridTableStyle(); it give me "The Type or name sapce 'DataGridTableStyle 'could not be found" also I have the following at the begining of the program.. using System;
2
2111
by: kerpal | last post by:
Hi all, 1. Could anyone pls clarify the difference between setting the AlternatingBackColor property in DataGridTableStyle and in DataGrid?? 2. How come BackColor and AlternatingBackColor are both associated with the ODD-numbered rows of the grid as stated in msdn?? Thank you and happy new year!!
4
5848
by: Brett Romero | last post by:
I have the following DataGridTableStyle: DataGridTableStyle gridTableStyle = new DataGridTableStyle(); gridTableStyle.MappingName = "myStyle"; DataGridTextBoxColumn dgsc = new DataGridTextBoxColumn(); dgsc.MappingName = "FirstName"; dgsc.HeaderText = "First Name"; dgsc.Width = 30; dgsc.TextBox.Enabled = false; gridTableStyle.GridColumnStyles.Add(dgsc);
9
1448
by: Brett Romero | last post by:
When I create this table and add it to my DataGrid (framework v1.1), the TableStyle works fine: DataTable dt = new DataTable(); DataColumn dc = new DataColumn("AreaCode"); DataColumn dctwo = new DataColumn("Test"); dt.Columns.Add(dc); dt.Columns.Add(dctwo); I have the style set to only show AreaCode. However, when I use a
3
4300
by: nita | last post by:
I'm just starting out, and it's incredibly frustrating when I see sample code and then try to implement it. Case in point. I'm populating a collection then binding it to a datagrid. That works great. The problem is the columns are in the wrong order. OK. I'll use the datagridtablestyle. But when I add the following statement; Dim tableStyle As New DataGridTableStyle I get an error when I build the project;
7
12633
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's the background for my question... Before I switched my application over to the Fx 2.0, I used a DataGrid to display my data. I would store different DataGridTableStyles (each one with a custom set of columns) in the DataGrid.TableStyles property...
0
1663
by: Guillaume | last post by:
Hi, I have an ArrayList filled with many Alarm object ( i will ad next this class definition). I use this arraylist as a datasource for my datagrid. I want to apply some table style, but it does not work at all. this is my code : first, the alarm class. class Alarm
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.