roxane101
Messages postés28Date d'inscriptionvendredi 12 mai 2006StatutMembreDernière intervention26 décembre 2006
-
28 mai 2006 à 14:24
roxane101
Messages postés28Date d'inscriptionvendredi 12 mai 2006StatutMembreDernière intervention26 décembre 2006
-
28 mai 2006 à 22:58
Bonjour
je veux changer la largeur d'une colonne de datagrid.
j'ai trouvé une methode : grid.PreferredColumnWidth=valeur.
mais cette methode s'applique sur toutes les colonnes et moi je
veux modifier la largeur d'une seule colonne.
Merci pour votre aide.
/.... make sure your DataGrid is using a tablestyle
dataGrid1.DataSource = _dataSet.Tables["customers"];
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "customers";
dataGrid1.TableStyles.Add(dgts);
//......
//method to set a column with by colnumber
public void SetColWidth(DataGridTableStyle tableStyle, int colNum, int width)
{
try
{
tableStyle.GridColumnStyles[colNum].Width = width;
tableStyle.DataGrid.Refresh();
}
catch{} //empty catch .. do nothing
}
/.... make sure your DataGrid is using a tablestyle
dataGrid1.DataSource = _dataSet.Tables["customers"];
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = "customers";
dataGrid1.TableStyles.Add(dgts);
//......
//method to set a column with by colnumber
public void SetColWidth(DataGridTableStyle tableStyle, int colNum, int width)
{
try
{
tableStyle.GridColumnStyles[colNum].Width = width;
tableStyle.DataGrid.Refresh();
}
catch{} //empty catch .. do nothing
}