473,396 Members | 1,836 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,396 software developers and data experts.

formating datagrid

hi there...

i fill my datagrid with a DataTable :

DataTable DA = new DataTable();
sqlDA.Fill(DA);
dataGridAdresse.DataSource = DA;

now i would like to formate my datagrid but i don't know how to use
tableStyle with DataTable.
who do i set the width of a certain column ??
is there anyone who could help me or provide me some example ???

thank you very much !!!

jonas knaus

jo*********@naviti.ch
Nov 15 '05 #1
3 1396
Can you read vb.net code? Here is an example.
Suppose you have a datatable.

Dim DA as datatable = new dataTable("MyTable")
//Suppose you have two column in DA, say "No" and "Name"

Dim tbs as DatagridTableStyle
tbs.mappingName = "MyTable"
tbs.gridlinecolor = system.drawing.color.lightgray
//....you can set other attribute here.

Dim tbc1 as new datagridtextboxcolumn()
tbc1.MappingName = "No"
tbc1.width = 40
tbs.gridstyles.add(tbc1)

Dim tbc2 as new datagridTextboxColumn()
tbc2.MappingName ="Name"
tbc2.width = 50
tbs.gridstyles.add(tbc2)
dataGridAdresse.DataSource = nothing
datagridAdresse.tablestyles.add(tbs)
dataGridAdresse.DataSource =DA

Hope it helps.
Tracey
-----Original Message-----
hi there... i fill my datagrid with a DataTable :
DataTable DA = new DataTable();
sqlDA.Fill(DA);
dataGridAdresse.DataSource = DA;

now i would like to formate my datagrid but i don't know
how to use tableStyle with DataTable. who do i set the
width of a certain column ??is there anyone who could help me or provide me some example ???
thank you very much !!!

jonas knaus

jo*********@naviti.ch
.

Nov 15 '05 #2

"Jonas Knaus" <jo*********@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
who do i set the width of a certain column ??
is there anyone who could help me or provide me some example ???
Hi there,

I've been playing with this, but haven't got it totally right yet. I wrote a
class called the DataGridColumnSizer that may give you a good starting
point. It's available from here:

http://www.tobinharris.com/default.asp?id=11&mnu=11

An example of the key code for setting column widths is as follows:

inGrid.TableStyles[0].GridColumnStyles[0].Width = 10

This would set the width of the first table, first column to 10

HTH

Tobin
thank you very much !!!

jonas knaus

jo*********@naviti.ch

Nov 15 '05 #3
hi all

thanks for your help
jonas
"Tobin Harris" <to********************@breathemail.net> schrieb im
Newsbeitrag news:bk************@ID-135366.news.uni-berlin.de...

"Jonas Knaus" <jo*********@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
who do i set the width of a certain column ??
is there anyone who could help me or provide me some example ???
Hi there,

I've been playing with this, but haven't got it totally right yet. I wrote

a class called the DataGridColumnSizer that may give you a good starting
point. It's available from here:

http://www.tobinharris.com/default.asp?id=11&mnu=11

An example of the key code for setting column widths is as follows:

inGrid.TableStyles[0].GridColumnStyles[0].Width = 10

This would set the width of the first table, first column to 10

HTH

Tobin
thank you very much !!!

jonas knaus

jo*********@naviti.ch


Nov 15 '05 #4

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

Similar topics

1
by: Diogo Alves - Software Developer | last post by:
Hi there, I have a datagrid that have a DateTime Column, that I built with this code: DataGridTextBoxColumn ExcColumn; ExcColumn= dgExc.TableStyles.GridColumnStyles as DataGridTextBoxColumn;...
1
by: Tayo | last post by:
What is best way of having a consistent datagrid format on multiple pages? Any ideas welcome Tayo
3
by: Tina | last post by:
I have a datagrid where I specified {0:###,###,###} at design time. However sometimes I am putting percentages in the grid instead of money and I want to change the formating to {##%}. I've...
2
by: Tim::.. | last post by:
Hi I'm trying to create a pager that allows you to show records by year and month! I am getting close but would really appritiate some help! Can someone please tell me how I convert the value of...
1
by: thechaosengine | last post by:
Hi all, I'm trying to format a date in a bound datagrid. In order to do this I've placed the following as an attribute to the bound column in question: DataFormatString="{0:dd/mm/yyyy}" ...
2
by: Bruce A. Julseth | last post by:
How do I make a column in a DataGrid have the following fomat xx.xx i.e. FormatNumber(??????, 2, TriState.True) Thank you...
2
by: Dave Prouten | last post by:
Hi all, I am trying to format a textbox which is data bound to a datagrid using the following syntax txtReportDate.DataBindings.Add("Text", dvHistory, "Start Date") I need to display the...
1
by: Thomas Beyerlein | last post by:
Hello, I am loading a dataGrid and formatting it with datagridtablestyle, but when it loads different info it does not clear the old. With out the formatting the code works. I have tried clearing...
0
by: musawer | last post by:
Can Someone give a good link for C# Winform DataGrid Text Style Formating (Font,Color,Size etc)... Quick reply will be highly appreciated... Thanks...
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: 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
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
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...
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,...
0
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...
0
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...
0
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,...

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.