次の問題について助けていただきたいです。
クライアントとそのリクエストに関するmySQL/winformsアプリケーションがあります。ある時点で、Tabcontrole を作成したいと考えています。このタブ コントロールのタブは実行時に作成されます。タブの数は、クライアントからの要求の数によって異なります。タブでは、多くのコントロール (テキスト ボックス、ボタン、ea) も実行時に作成されます。
今、私は立ち往生するところまで来ました。タブのコントロールにアクセスして、その値をデータベースに保存するにはどうすればよいですか?
これは、コントロールを作成するために使用するコードです。
private void GetAllrequestsForSameClient(string client)
{
MySqlConnection MijnConnectie = new MySqlConnection(Constanten.DATABASECONNSTRING);
string query = "select * from gedeeldeNotepadDB.requests WHERE requestsForeClient = '" + client + "';";
MySqlCommand mysqlcommand = new MySqlCommand(query, MijnConnectie);
MySqlDataReader myReader;
try
{
MijnConnectie.Open();
myReader = mysqlcommand.ExecuteReader();
while (myReader.Read())
{
string onderwerp = myReader.GetString("onderwerpBijstandAanvraag");
NieweTab(tabControl1, onderwerp);
}
MijnConnectie.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
リーダーで、メソッド「NieweTab(tabControl1, onderwerp);」を呼び出します。これはコードです:
public void NieweTab(TabControl tabControl1, string onderwerp)
{
TabPage tabPage1 = new System.Windows.Forms.TabPage();
Label lblvan = new System.Windows.Forms.Label();
Label lblPeriode = new System.Windows.Forms.Label();
Label lblTot = new System.Windows.Forms.Label();
MaskedTextBox txtPeriodeTot = new System.Windows.Forms.MaskedTextBox();
MaskedTextBox txtPeriodeVan = new System.Windows.Forms.MaskedTextBox();
Label lblDraagkracht = new System.Windows.Forms.Label();
TextBox textBox1 = new System.Windows.Forms.TextBox();
Button btnTabIsKlaar = new System.Windows.Forms.Button();
btnTabIsKlaar.Click += new System.EventHandler(MyButtonHandler);
tabControl1.Controls.Add(tabPage1);
tabControl1.Location = new System.Drawing.Point(12, 111);
tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0;
tabControl1.Size = new System.Drawing.Size(533, 209);
tabControl1.TabIndex = 38;
//followed by a lot of layout code.....
質問が何であるかを明確にしたことを願っていますか?私の問題を解決してくれてありがとう。