![]() |
sınıflar arası veri aktarımı |
Post Reply ![]() |
|
Author | |
sylend ![]() Newbie ![]() Joined: 30 Aralık 2020 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() Posted: 30 Aralık 2020 at 19:36 |
kolay gelsin arkadaşlar
benim 2 sınıfım var. bir sınıfımdan diğerine txtbox daki değeri aktarmak istiyorum fakat SystemNullReferanceException hatası alıyorum ne yaptıysam bulamadım çözümü yardımcı olursanız sevinirim. Hatayı verdiği kısım formOlustur sınıfının içerisinde degerGonder metodu çalıştığında Miktar değişkenin de veriyor. Kodlarım aşağıdadır: public class User { public static dynamicSistem = null; public void YagmurlamaParametreGir(cxSistem cx) { Sistem = cx; FormOlustur formOlustur = new FormOlustur(); formOlustur.formOlustur(); } public int Miktar = 0; public int Miktar2 = 0; public int Miktar3 = 0; public int Miktar4 = 0; public int CalismaSaniyesi = 0; public int ustKademe = 0; public void yagmurlamaCagir(dynamic Sistem) { } } public class FormOlustur { public static dynamicSistem = null; User user = new User(); Form ygmrpar = new Form(); public void formOlustur() { ygmrpar.SuspendLayout(); #region Label_Text_Button // label1 Label label1 = new Label(); label1.AutoSize = true; label1.Location = new System.Drawing.Point(6, 9); label1.Name = "label1"; label1.Size = new System.Drawing.Size(90, 13); label1.TabIndex = 0; label1.Text = "Lot Miktarı Giriniz:"; // // label2 Label label2 = new Label(); label2.AutoSize = true; label2.Location = new System.Drawing.Point(6, 35); label2.Name = "label2"; label2.Size = new System.Drawing.Size(90, 13); label2.TabIndex = 0; label2.Text = "Lot Miktarı Giriniz:"; // // label3 Label label3 = new Label(); label3.AutoSize = true; label3.Location = new System.Drawing.Point(6, 61); label3.Name = "label3"; label3.Size = new System.Drawing.Size(90, 13); label3.TabIndex = 0; label3.Text = "Lot Miktarı Giriniz:"; // // txtLot1 TextBox txtLot1 = new TextBox(); txtLot1.Location = new System.Drawing.Point(102, 6); txtLot1.Name = "txtLot1"; txtLot1.Size = new System.Drawing.Size(52, 20); txtLot1.TabIndex = 1; // // txtLot3 TextBox txtLot3 = new TextBox(); txtLot3.Location = new System.Drawing.Point(102, 58); txtLot3.Name = "txtLot3"; txtLot3.Size = new System.Drawing.Size(52, 20); txtLot3.TabIndex = 1; // // txtLot2 TextBox txtLot2 = new TextBox(); txtLot2.Location = new System.Drawing.Point(102, 32); txtLot2.Name = "txtLot2"; txtLot2.Size = new System.Drawing.Size(52, 20); txtLot2.TabIndex = 1; // // label4 Label label4 = new Label(); label4.AutoSize = true; label4.Location = new System.Drawing.Point(184, 35); label4.Name = "label4"; label4.Size = new System.Drawing.Size(119, 13); label4.TabIndex = 0; label4.Text = "Çalışma Saniyesi Giriniz:"; // // txtCalismaSaniyesi TextBox txtCalismaSaniyesi = new TextBox(); txtCalismaSaniyesi.Location = new System.Drawing.Point(309, 32); txtCalismaSaniyesi.Name = "txtCalismaSaniyesi"; txtCalismaSaniyesi.Size = new System.Drawing.Size(52, 20); txtCalismaSaniyesi.TabIndex = 1; // // label5 Label label5 = new Label(); label5.AutoSize = true; label5.Location = new System.Drawing.Point(172, 9); label5.Name = "label5"; label5.Size = new System.Drawing.Size(131, 13); label5.TabIndex = 0; label5.Text = "Kaç Kademe Üstten Satış:"; // // txtSatisKademe TextBox txtSatisKademe = new TextBox(); txtSatisKademe.Location = new System.Drawing.Point(309, 6); txtSatisKademe.Name = "txtSatisKademe"; txtSatisKademe.Size = new System.Drawing.Size(52, 20); txtSatisKademe.TabIndex = 1; // // btnBaslat Button btnBaslat = new Button(); btnBaslat.Location = new System.Drawing.Point(187, 61); btnBaslat.Name = "btnBaslat"; btnBaslat.Size = new System.Drawing.Size(75, 23); btnBaslat.TabIndex = 2; btnBaslat.Text = "Başlat"; btnBaslat.UseVisualStyleBackColor = true; btnBaslat.Click += new System.EventHandler(btnBaslat_Click); // // btnDurdur Button btnDurdur = new Button(); btnDurdur.Location = new System.Drawing.Point(268, 61); btnDurdur.Name = "btnDurdur"; btnDurdur.Size = new System.Drawing.Size(75, 23); btnDurdur.TabIndex = 2; btnDurdur.Text = "Durdur"; btnDurdur.UseVisualStyleBackColor = true; btnDurdur.Click += new System.EventHandler(btnDurdur_Click); //form ygmrpar.Text = "Yağmurlama Parametrelerini Giriniz:"; ygmrpar.StartPosition = FormStartPosition.CenterScreen; ygmrpar.ControlBox = false; ygmrpar.Name = "ygmr"; ygmrpar.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); ygmrpar.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ygmrpar.ClientSize = new System.Drawing.Size(366, 88); ygmrpar.ResumeLayout(false); ygmrpar.PerformLayout(); #endregion #region NesneEkle ygmrpar.Controls.Add(label1); ygmrpar.Controls.Add(label2); ygmrpar.Controls.Add(label3); ygmrpar.Controls.Add(label4); ygmrpar.Controls.Add(label5); ygmrpar.Controls.Add(txtLot1); ygmrpar.Controls.Add(txtLot2); ygmrpar.Controls.Add(txtLot3); ygmrpar.Controls.Add(txtSatisKademe); ygmrpar.Controls.Add(txtCalismaSaniyesi); ygmrpar.Controls.Add(btnBaslat); ygmrpar.Controls.Add(btnDurdur); #endregion ygmrpar.ShowDialog(); } public void btnBaslat_Click(object sender, EventArgs e) { degerGonder(); user.yagmurlamaCagir(Sistem); } public void btnDurdur_Click(object sender, EventArgs e) { User.Sistem.RobotStop(); ygmrpar.Close(); Sistem.Mesaj("Tüm Robotlar Durduruldu."); } public void degerGonder() { user.Miktar = Convert.ToInt32(txtLot1.Text); user.Miktar2 = Convert.ToInt32(txtLot2.Text); user.Miktar3 = Convert.ToInt32(txtLot3.Text); user.ustKademe = Convert.ToInt32(txtSatisKademe.Text); if (txtCalismaSaniyesi.Text == "") { user.CalismaSaniyesi = 0; } else { user.CalismaSaniyesi = Convert.ToInt32(txtCalismaSaniyesi.Text); } } private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; public System.Windows.Forms.TextBox txtLot3; public System.Windows.Forms.TextBox txtLot2; private System.Windows.Forms.Label label4; public System.Windows.Forms.TextBox txtCalismaSaniyesi; private System.Windows.Forms.Label label5; public System.Windows.Forms.TextBox txtSatisKademe; private System.Windows.Forms.Button btnBaslat; private System.Windows.Forms.Button btnDurdur; public System.Windows.Forms.TextBox txtLot1; } |
|
![]() |
Post Reply ![]() |
|
Tweet
|
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |