Adjust datagrid width size with dataset fields size?

tonhinbm

Member
Joined
Apr 13, 2005
Messages
8
Programming Experience
Beginner
First of all I'm from Spain and my English is very poor, and I'm new in this forum so excuse me if the post isn't in the correct thread.
Could I fixed the datagrid width with the dataset fields size?.
In ASP.NET when I bind a dataset to a datagrid the dataset cover completely the datagrid size but in vb.net you must write a predeterminated size for each column and you can't use with="25%"....or I think this...
Can anyone help me?
Thanks.
 
you can adjust a column of your datagrid by using the datagridtablestyle.
try to search about datagridtablestyle in vb.net.
it helps you a lot.
 
This is an example of the use Columns Style by program. You can also use the IDE of Vb.NET

VB.NET:
Public Sub Columnas()
	Dim TSTemas As New DataGridTableStyle
	TSTemas.MappingName = "Ayuda"
	TSTemas.AllowSorting = True
	Dim oClase As New DataGridTextBoxColumn
	oClase.MappingName = "Clase"
	oClase.HeaderText = "CLASE"
	oClase.Width = 55
	TSTemas.GridColumnStyles.Add(oClase)
	Dim oTema As New DataGridTextBoxColumn
	oTema.MappingName = "Tema"
	oTema.HeaderText = "TEMA"
	oTema.Width = 250
	TSTemas.GridColumnStyles.Add(oTema)
	Dim oTopico As New DataGridTextBoxColumn
	oTopico.MappingName = "Topico"
	oTopico.HeaderText = "TOPICO"
	oTopico.Width = 350
	TSTemas.GridColumnStyles.Add(oTopico)
	myGrid.TableStyles.Add(TSTemas)
  End Sub
 
Back
Top