Witam, posiadam pewnien problem. Otóż mam 1 formę Addnotatka.cs i klasę w oddzielnym pliku Notatka.cs.
Problem polega na tym, że za nic nie moge odczytać zmiennych z Addnotatka.cs, kompilator nie wywala mi błędu i zamiast pokazać mi zawartość zmiennej to nic mi nie wyświetla (w sensie zawartości zmiennych).
Addnotatka.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Tajny_notatnik_BETA { public partial class Addnotatka : Form { protected string nazwaadd; public string hasloadd; public Addnotatka() { InitializeComponent(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked == true) { haslotb.Visible = true; label3.Visible = true; checkBox1.Top = 188; haslotb.Select(); } else { haslotb.Visible = false; label3.Visible = false; checkBox1.Top = 132; haslotb.Text = ""; nazwatb.Select(); } } private void button2_Click(object sender, EventArgs e) { haslotb.Visible = false; label3.Visible = false; checkBox1.Top = 132; haslotb.Text = ""; nazwatb.Select(); nazwatb.Text = ""; checkBox1.Checked = false; this.Close(); } private void nazwatb_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { nazwaadd = nazwatb.Text; hasloadd = "test"; label4.Text = nazwaadd; label5.Text = hasloadd; Notatka notatka = new Notatka(); notatka.dodajnotatke(); } } }
Notatka.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Tajny_notatnik_BETA { class Notatka : Addnotatka { int id; string nazwa; string haslo; string tresc; public void dodajnotatke() { id += 1; nazwa = nazwaadd; haslo = hasloadd; // if (haslo == "") // { MessageBox.Show("HASŁO TO" + haslo +"<<<"); // } // else //{ // MessageBox.Show("HASLO TO: " + haslo + " hehe"); // } } public void zapisznotatke() { } public void wyswietlnotatke() { } } }
PS usunąłem konstruktor w Notatka.cs bo myślałem że tam coś źle zrobiłem, ale to nie on był tego przyczyną. Za okazaną pomoc dziękuję.