1
Windows 폼에서 프롬프트를 사용할 때 어떻게 텍스트 상자를 자동으로 선택하겠습니까? 아래 코드는 내가 시도한 것을 보여 주지만 여전히 텍스트 상자가 아니라 버튼에 초점을 맞추고 있습니다. 도움과 도움을 미리 감사드립니다.Windows C# 양식 : 프롬프트에 초점을 텍스트 상자
Form prompt = new Form();
prompt.Width = 500;
prompt.Height = 200;
prompt.Text = caption;
Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Ok", Left = 50, Width = 100, Top = 90 };
confirmation.Click += (sender, e) => { prompt.Close(); };
textBox.Select();
textBox.Focus();
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.Controls.Add(textBox);
prompt.ShowDialog();
return textBox.Text;
작동하지 마십시오! 감사! 곧 당신의 대답을 받아 들일 것입니다. – AustinT
@AustinTruong 맞아요, 편집을보십시오 (이번에 테스트했습니다). – Servy