0
私はこれをたくさん検索しましたが、うまくいく答えが見つかりませんでした。これは私が探しているものです。フォームのtextbox.textを取得
私にはテキストボックスのあるウィンドウがあります。私はボタンを押すと、私はクラスのインスタンスを作成し、私はクラスにte textbox.textを読んでみたいです。 これは私が試したものです:
テキストボックスの休暇イベント(名テキストボックス= textBox_klantnaam):
public string klantNaam
{
get { return textBox_klantnaam.Text; }
set { textBox_klantnaam.Text = value; }
}
onclickのボタン:
klantNaam = textBox_klantnaam.Text;
同じ形式で私は財産を持っています
private void button1_Click(object sender, EventArgs e)
{
Class_licentiemanager SchrijfLicentieBestand = new Class_licentiemanager();
SchrijfLicentieBestand.schrijfLicBestand();
}
textbox.textを読み込み、それをfiに書き込むクラス。 le プロパティ "klantNaam"は空白に見えますか?
namespace Opzet_Leeg_Framework
{
class Class_licentiemanager
{
Class_Logging logging = new Class_Logging();
public static Form_Licentiemanager Licentiemanager = new Form_Licentiemanager();
public void schrijfLicBestand()
{
using (StreamWriter w = new StreamWriter(Settings.applicatiePad + Form1.SettingsMap + Form1.Applicatienaam + ".lic"))
try
{
try
{
w.WriteLine("test line, works fine");
w.WriteLine("Naam klant : " + Licentiemanager.klantNaam); //Empty , no line ???
}
catch (Exception e)
{
logging.witeToLog("FOUT", "Het opslaan van het licentiebestand is mislukt", 1);
logging.witeToLog("FOUT", "Melding : ", 1);
logging.witeToLog("FOUT", e.ToString(), 1);
}
}
finally
{
w.Close();
w.Dispose();
}
}
}
}
おかげで多くのことを、これは動作します。 – Hansvb