Parcourir une datatable et generer un textbox
Bonjour, je souhaite parcourir une datatable et voudrais generer
5 textbox (nombre de colonne) alignés l'un en dessous de l'autre, un peu comme un datagridview mais pouvoir disposer mes textbox comme bon me semble.
Voila où j'en suis, mais il y a peut etre plus simple et mieux à faire ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
MonDataAdapter = new SqlDataAdapter(CmdSelect);
dataset_table = "param";
MonDataAdapter.Fill(ds, dataset_table);
foreach( DataRow row in ds.Tables[dataset_table].Rows)
{
foreach (DataColumn column in ds.Tables[dataset_table].Columns)
{
this.textBox.key = new System.Windows.Forms.TextBox();
this.textBox.key.Location = new System.Drawing.Point(445, 84+key*10);
this.textBox.key.Name = textBox.key.ToString();
this.textBox.key.TabIndex = 24;
this.textBox.key.Text = row[column].ToString();
}
} |
le key serait l'index de la collection.
Mais je trouve le code assez lourd.
Auriez vous une meilleure suggestion? Merci