473,811 Members | 3,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

DataGridTableSt yle tableStyle = new DataGridTableSt yle();
tableStyle.Mapp ingName = "Language";
DataGridTextBox Column grdColStyle1 = new DataGridTextBox Column();
grdColStyle1.He aderText = "Language(s ) Spoken";
grdColStyle1.Ma ppingName = "Language";
grdColStyle1.Wi dth = 200;
DataGridColumnS tyle [] dgcs = {grdColStyle1};
tableStyle.Grid ColumnStyles.Ad dRange(dgcs);
this.dgLanguage s.TableStyles.A dd(tableStyle);
How can I resize columns and retain current formats?

Peter
--
Thanks
-------------------
cz****@wsinc.co m
Nov 15 '05 #1
2 2108
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 DataGridTableSt yle 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
DataGridTableSt yle, for example:

tableStyle.Alte rnatingBackColo r = dgLanguages.Alt ernatingBackCol or;
tableStyle.Back groundColor = dgLanguages.Bac kgroundColor;
...

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.mi crosoft.com> wrote in message
news:gG******** ******@cpmsftng xa07.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 DataGridTableSt yle 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
DataGridTableSt yle, for example:

tableStyle.Alte rnatingBackColo r = dgLanguages.Alt ernatingBackCol or;
tableStyle.Back groundColor = dgLanguages.Bac kgroundColor;
..

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
11515
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 anticipation, Regards,
2
3960
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 ValidatingXMLReader. After loading the document (and validating it) I assume that the resulting doc will (as appropriate) have elements with attributes set to their default values in those cases where there was nothing specified in the input XML file. However,...
1
2224
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 looked in my reference books and looked at menus and toolbars and haven't found a way. TIA
2
1740
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 Visual Studio from reformatting my page when I drag and drop web form elements. Eirik Eldorsen
4
1156
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 -- Paul G Software engineer.
0
1300
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 datagrid.select(), because I have multiple rows and highlight effect of selected rows will be gone if I click on one of them. Then I lose the visual clue of these rows. The best way would be using different backgroup color on those rows. Could anybody tell...
5
1720
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
1593
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 hand ons the Pro Version, but the thing is that, I remember that in the Express version, you where able to drag and drop the datagrid control on the form, select it's properties and then from the links at the bottom of the properties choose...
3
3150
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 there is something missing or the values are incorrect. <input type="text" name="camount" tabindex="4" value="<?php echo $form->value("camount"); ?>" > When i edit this information i retrieve the value in the following manner <input...
0
10651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
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
9208
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...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
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
3
3020
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.