저는 1 주일 동안이 문제에 어려움을 겪었으므로 그것에 대해 다른 질문은 없습니다. Accessing Forms data from another form과 같은 것을해야하지만 두 번째 폼의 첫 번째 폼의 코드에있는 변수에 액세스해야하며 두 번째 폼에서 click 이벤트가 발생해야합니다. 또한두 양식을 사용하여 첫 번째 양식에서 변수에 액세스하십시오.
namespace Sudoku
{
public partial class difficultyForm : Form
{
string difficulty = "";
public difficultyForm()
{
InitializeComponent();
}
private void enterButton_Click(object sender, EventArgs e)
{
difficulty = difficultyTextBox.Text;
if (difficulty != "1" && difficulty != "2" && difficulty != "3" && difficulty != "4" && difficulty != "5")
MessageBox.Show("The difficulty must be an integer from 1 to 5.", "Difficulty Error", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
else
{
this.Hide();
}
내가 C에서 # 멍청한 놈 이니 여기
namespace Sudoku
{
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
difficultyForm difForm = new difficultyForm();
public string difficulty = "";
private void generateNewPuzzleMenuItem_Click(object sender, EventArgs e)
{
generateBegin();
}
private void generateBegin()
{
difForm.Show();
difForm.difficultyTextBox.Text = "";
difForm.difficultyTextBox.Focus();
그리고 두 번째 양식의 (difficultyForm의) 코드의 일부는 다음과 같습니다
는 첫 번째 양식의 (mainForm의) 코드의 일부입니다 그래서 당신이 위대한 될 다른 팁 있다면, 고마워.참고 : 코드에서 더 아래쪽에 있기 때문에 문자열을 사용하고 있습니다. 따라서 정수를 사용하지 말아주세요. 감사합니다.
변수의 값을 첫 번째 형식으로 가져 오거나 설정 하시겠습니까? – Servy
[다른 양식의 양식 데이터 액세스] 가능한 복제본 (http://stackoverflow.com/questions/21577732/accessing-forms-data-from-another-form) – Joe
기본 양식의 텍스트를 공백으로 표시해서는 안됩니다. 다른 양식 또는 텍스트 상자의 포커스 설정. 그러한 것들은 두 번째 형태로 이루어져야합니다. 텍스트 상자는 공개적으로 노출되지 않아야합니다. – Servy