473,513 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Define Columns

Hi everybody

I need your help
With this code read data from table Usuarios and I show it in a Datagrid.

cn.Open ();
SqlDataAdapter da = new SqlDataAdapter("Select Usuario,Apellidos from
Usuarios;",cn);
DataSet ds = new DataSet();
da.Fill(ds,"Usuarios");
DataView dvUsuarios = new DataView(ds.Tables["Usuarios"]);
dgUsuarios.DataSource = dvUsuarios;

How can I do to define headers and width of columns?

Thx
Pablo Salazar
Guatemala
Nov 16 '05 #1
4 1791
Apply a DataGridTableStyle to the grid to control its appearance

DataGridTableStyle tableStyle = new DatagridTableStyle()
TableStyle.MappingName = "Usuarios"

DataGridTextBoxColumn column1 = new DatgridTextBoxColumn()
column1.MappingName = "Usuario"
column1.HeaderText = "My Column Header"
column1.Width = 150

tableStyle.GridColumnStyles.Add(column1)

// repeat for other column(s

datGrid1.TableStyles.Add(tableStyle)
Charlie
Nov 16 '05 #2
thanks.
That's i was looking for.
"Charlie Williams" <an*******@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
Apply a DataGridTableStyle to the grid to control its appearance.

DataGridTableStyle tableStyle = new DatagridTableStyle();
TableStyle.MappingName = "Usuarios";

DataGridTextBoxColumn column1 = new DatgridTextBoxColumn();
column1.MappingName = "Usuario";
column1.HeaderText = "My Column Header";
column1.Width = 150;

tableStyle.GridColumnStyles.Add(column1);

// repeat for other column(s)

datGrid1.TableStyles.Add(tableStyle);

Charlie

Nov 16 '05 #3
Apply a DataGridTableStyle to the grid to control its appearance

DataGridTableStyle tableStyle = new DatagridTableStyle()
TableStyle.MappingName = "Usuarios"

DataGridTextBoxColumn column1 = new DatgridTextBoxColumn()
column1.MappingName = "Usuario"
column1.HeaderText = "My Column Header"
column1.Width = 150

tableStyle.GridColumnStyles.Add(column1)

// repeat for other column(s

datGrid1.TableStyles.Add(tableStyle)
Charlie
Nov 16 '05 #4
thanks.
That's i was looking for.
"Charlie Williams" <an*******@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
Apply a DataGridTableStyle to the grid to control its appearance.

DataGridTableStyle tableStyle = new DatagridTableStyle();
TableStyle.MappingName = "Usuarios";

DataGridTextBoxColumn column1 = new DatgridTextBoxColumn();
column1.MappingName = "Usuario";
column1.HeaderText = "My Column Header";
column1.Width = 150;

tableStyle.GridColumnStyles.Add(column1);

// repeat for other column(s)

datGrid1.TableStyles.Add(tableStyle);

Charlie

Nov 16 '05 #5

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

Similar topics

2
317
by: Pablo Salazar | last post by:
Hi everybody I need your help With this code read data from table Usuarios and I show it in a Datagrid. cn.Open (); SqlDataAdapter da = new SqlDataAdapter("Select Usuario,Apellidos from...
2
249
by: Pablo Salazar | last post by:
Hi everybody I need your help With this code read data from table Usuarios and I show it in a Datagrid. cn.Open (); SqlDataAdapter da = new SqlDataAdapter("Select Usuario,Apellidos from...
0
268
by: Pablo Salazar | last post by:
Hi everybody I need your help With this code read data from table Usuarios and I show it in a Datagrid. cn.Open (); SqlDataAdapter da = new SqlDataAdapter("Select Usuario,Apellidos from...
1
1388
by: karunakar | last post by:
Iam binding datagrid using Datatable . How to define width for Datagrid header dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32))); using this i was populating datagrid Regards
0
7267
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
7175
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...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5100
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...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
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 ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
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...

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.