Ich habe zwei Formulare, und ich möchte die JSON-URL und die Daten von der ersten Form in die zweite Form verwenden.Übertragung von JSON-URL von Formular 1 zu Formular 2
Form 1: dies ist, wo i die zweite Form geöffnet
private void button1_Click(object sender, EventArgs e)
{
var json = new WebClient().DownloadString("http://dev.ibeaconlivinglab.com:1881/companybyuuid?uuid="+textBox1.Text);
List<details> detailsList = JsonConvert.DeserializeObject<List<details>>(json);
foreach (details dets in detailsList)
{
if (textBox1.Text == dets.uuid)
{
this.Hide();
notifyIcon1.Visible = false;
Form2 secondForm = new Form2();
secondForm.Show();
}
else
{
MessageBox.Show("Company not found.");
}
}
}
zweite Form;
private void Form2_Load(object sender, EventArgs e){
Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width,
Screen.PrimaryScreen.WorkingArea.Bottom - Height);
Label namelabel = new Label();
namelabel.Location = new Point(13, 30);
foreach (details dets in detailsList)
{
namelabel.Text = dets.id;
this.Controls.Add(namelabel);
}
}
Ich kann die URL nicht zur zweiten Form verwenden. – discable10
Siehe bearbeitete Antwort. Übergeben Sie einfach das, was Sie benötigen, indem Sie die Signatur der Konstruktormethode ändern. –
Was ist mit dem JsonText? – discable10