에서 만든 컨트롤에서 값을 얻는 방법 : 나는 고객과 그들의 요구 abbout 인 MySQL은/윈폼 응용 프로그램을 가지고나는 다음과 같은 문제에 도움 싶습니다 런타임
합니다. 어떤 시점에서 저는 Tabcontrole을 만들고 싶습니다. 이 tabcontrole의 탭은 런타임에 작성됩니다. 탭 수는 클라이언트의 요청 수에 따라 다릅니다. 탭에서 런타임에 여러 컨트롤 (텍스트 상자, 단추, e.a.)이 만들어집니다.
이제 막 달라 붙었습니다. 탭의 컨트롤에 액세스하여 값을 데이터베이스에 저장하려면 어떻게합니까? "NieweTab (tabControl1, onderwerp)"I이 방법 involke 리더에
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);
}
}
:
이 제가
컨트롤을 만들 때 사용하는 코드 나는 문제가 무엇인지 명확하게 한 희망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.....
: 이 코드인가? 미리 문제를 해결해 주셔서 감사합니다.
Tab의 모든 컨트롤과 함께 사용자 정의 컨트롤을 만들고 로컬 목록 (목록)을 사용하여 액세스하십시오. 당신이 어려운 길을 원한다면 ... foreach this를 사용하십시오. 이름으로 제어 및 검색하십시오. –
답장을 보내 주셔서 감사합니다.하지만 어떻게 해야할지 이해할 수 없습니까? 좀 더 힌트를 주시겠습니까? –