Hello everyone,
I'm new here and a newbie at C#.
So heres the thing - I've created a 'Class Library' project that uses(runs) a Windows Form, and I would like to gather its input and use it in Class1.cs.
The codes are basic (almost no coding done) :
Class1.cs
Form1.cs (the design contains a single textbox and a button)
My goal is upon the button1_Click event to store the textBox1's value and pass that value to Class1.cs, aswell close the WindowsForm dialog.
But obviously I don't know to do any of it!
I'm new here and a newbie at C#.
So heres the thing - I've created a 'Class Library' project that uses(runs) a Windows Form, and I would like to gather its input and use it in Class1.cs.
The codes are basic (almost no coding done) :
Class1.cs
C#:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestClassLib
{
public class Class1
{
public static void WinFormTest()
{
System.Windows.Forms.Application.Run(new Form1());
}
}
}
Form1.cs (the design contains a single textbox and a button)
C#:
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 TestClassLib
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// return textBox1.Text; // it throws an error obviously
}
}
}
My goal is upon the button1_Click event to store the textBox1's value and pass that value to Class1.cs, aswell close the WindowsForm dialog.
But obviously I don't know to do any of it!