我想要一些关于以下问题的帮助:
我有一个关于客户及其请求的 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.....
我希望我已经明确了问题是什么?提前感谢您解决我的问题。