473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Retain DataGrid AutoFormat values

I have a DataGrid control on a form and I used the Auto Format feature to format the grid.

The problem is now if I resize a column in my code I loose some of the formats - some of the grid colors returns to default values. Here is the code that I use to resize a column.

DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Language";
DataGridTextBoxColumn grdColStyle1 = new DataGridTextBoxColumn();
grdColStyle1.HeaderText = "Language(s) Spoken";
grdColStyle1.MappingName = "Language";
grdColStyle1.Width = 200;
DataGridColumnStyle [] dgcs = {grdColStyle1};
tableStyle.GridColumnStyles.AddRange(dgcs);
this.dgLanguages.TableStyles.Add(tableStyle);
How can I resize columns and retain current formats?

Peter
--
Thanks
-------------------
cz****@wsinc.com
Nov 15 '05 #1
2 2087
Hello Peter,

Thanks for posting. According to your description, when you try to resize a
column in the auto-formatted DataGrid, some formats of the column get lost.
If I have misunderstood you, please correct me.

If we add a new DataGridTableStyle to the DataGrid, it will override the
default color settings of the DataGrid, which is set by "Auto Format". As a
result, we need to explicitly set the color of the newly created
DataGridTableStyle, for example:

tableStyle.AlternatingBackColor = dgLanguages.AlternatingBackColor;
tableStyle.BackgroundColor = dgLanguages.BackgroundColor;
...

I hope this helps.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
I got it thanks for your help!
""Felix Wang"" <v-*****@online.microsoft.com> wrote in message
news:gG**************@cpmsftngxa07.phx.gbl...
Hello Peter,

Thanks for posting. According to your description, when you try to resize a column in the auto-formatted DataGrid, some formats of the column get lost. If I have misunderstood you, please correct me.

If we add a new DataGridTableStyle to the DataGrid, it will override the
default color settings of the DataGrid, which is set by "Auto Format". As a result, we need to explicitly set the color of the newly created
DataGridTableStyle, for example:

tableStyle.AlternatingBackColor = dgLanguages.AlternatingBackColor;
tableStyle.BackgroundColor = dgLanguages.BackgroundColor;
..

I hope this helps.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3

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

Similar topics

5
by: samik_tanik | last post by:
I need to export a datagrid to Excel. I could did this. But, also need to keep the leading zeros in the data. How can I acheive this? Any help would be appreciated. -- Thanking you in...
2
by: Bill Cohagan | last post by:
In my app I'm validating an XML file against an XSD which contains several attribute default value specifications. I'm performing the validation via an xml document load() using a...
1
by: Catherine Jo Morgan | last post by:
If I use the autoformat option in Access2002 to make a form look a certain way, using the Form Design Wizard, is it possible to change later to a different autoformat option? If so, how? I've...
2
by: Eirik Eldorsen | last post by:
Is it possible to completely turn off autoformat in visual studio 2003? In the options, I've unchecked autoformat when save and autoformat on switch between design/html. But that does not stop...
4
by: Paul | last post by:
Hi I have a data grid where I am changing the colors of cells based on values that have been filled with a dataset. Just wondering if there is a way to set a border around each cell? Thanks --...
0
by: Karl | last post by:
Hi there, I want to change the backgroup color of certain datagrid rows. I don't want to use autoformat. I only want to change the color of the rows with wrong data. I don't want to use...
5
by: BartlebyScrivener | last post by:
I'm new to both Perl & Python. Is there a Python module or script somewhere comparable to the useful Perl module - Text::Autoformat? Thanks, BS
1
by: JJGarcia | last post by:
Hi everyone, I am not an expert in Visual basic, so excuse me if you guys find my question a little too easy, you'll see, I played around sometime with Visual Express 2005 then, I finally got mi...
3
by: raaman rai | last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation. When i add the information from a form, i retain the form values in the following way incase...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.