formating datagrid

  • Thread starter Thread starter Jonas Knaus
  • Start date Start date
J

Jonas Knaus

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

(e-mail address removed)
 
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 ??
 
Jonas Knaus said:
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
 
hi all

thanks for your help
jonas


Tobin Harris said:
Jonas Knaus said:
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

(e-mail address removed)
 
Back
Top