0
私は、データベースの列のテキストボックスとチェックボックスを生成するウィンドウを持っています:Image だから私は何かを変更して保存をクリックします。私はこれらを保存したい。だから私は、複数のテキストボックスでそれぞれのループのための必要があります。テキストボックスの量を検出
テキストボックスの数を検出する方法はありますか?ここで
は、テキストボックスやチェックボックスの作成方法をいくつかのコードです:
public firmCustomerTable()
{
InitializeComponent();
MySqlConnection connection;
config conf = new config();
connection = new MySqlConnection(conf.connection_string);
DataTable schema = null;
using (var con = new MySqlConnection(conf.connection_string))
{
using (var schemaCommand = new MySqlCommand("SELECT * FROM firmenkunden", con))
{
con.Open();
using (var reader = schemaCommand.ExecuteReader(CommandBehavior.SchemaOnly))
{
schema = reader.GetSchemaTable();
}
}
}
foreach (DataRow col in schema.Rows)
{
System.Windows.Controls.TextBox newTxt = new TextBox();
System.Windows.Controls.CheckBox onoff = new CheckBox();
// Add Label
newTxt.Text = col.Field<String>("ColumnName");
newTxt.Name = col.Field<String>("ColumnName");
newTxt.Width = 200;
// Add OnOff
onoff.HorizontalAlignment = HorizontalAlignment.Center;
onoff.Style = (Style)FindResource("CheckBoxStyle1");
onoff.VerticalAlignment = VerticalAlignment.Center;
// Add To Panel
sp.Children.Add(newTxt);
sp.Children.Add(onoff);
}
}
私は、彼らがグリッドやStackPanelの、またはコンテナのいくつかの種類でなければなりませんassusme。これらの子を照会してTextBoxesに制限するには十分であるべきです – Lennart
いくつかのコードを追加すると、コントロールの作成方法がわかります。 –
@ R.Rusev私はいくつかのコードを追加しました。 – xKushGene