Define Columns

P

Pablo Salazar

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top