.net 4.5를 사용하여 Winform 앱을 작성 중입니다.스크롤바를 창 상단으로 재설정하는 방법
내 프로젝트에는 버튼 만있는 창이 있습니다.
창이 표시 될 때 스크롤 막대가 필요한 지점에 동적으로 많은 컨트롤을 추가합니다.
일단 컨트롤이 추가되면 윈도우의 컨트롤 아래쪽으로 단일 버튼을 이동합니다.
단추를 컨트롤의 아래쪽으로 이동하는이 단계는 창을 맨 아래로 스크롤합니다. 나는 폼의 맨 아래로 버튼을 이동시키지 않으면 서이를 테스트했으며 스크롤은 맨 위에 머문다.
"this.VerticalScroll.Value = 0;"시도했습니다. 단추의 위치를 설정하기 전과 후에 모두. 나는이 1 개 버튼으로 이동되는 위치에 관계없이 정상에 창 수직 스크롤을 강제 할 수있는 방법
public SignoffSurvey(int task_id)
{
InitializeComponent();
this.task_id = task_id;
int form_top = 10;
int question_num = 0;
XmlDocument doc = new XmlDocument();
doc.Load(DBHandler.getSetting("files_directory") + "\\" + "questionaire.xml");
foreach (XmlNode node in doc.SelectNodes("/Questions/Question"))
{
question_num++;
string type = node.Attributes["type"].Value;
int top = 0;
Panel pnl = new Panel();
pnl.AutoSize = true;
pnl.Top = form_top;
pnl.Left = 10;
Label text_lbl = new Label();
text_lbl.Top = top;
text_lbl.AutoSize = true;
text_lbl.Text = node["text"].InnerText;
pnl.Controls.Add(text_lbl);
top += text_lbl.Height + 5;
if (type == "mc" || type == "mct")
{
XmlNode choices = node["choices"];
Boolean fc = false;
foreach (XmlNode choice in choices.ChildNodes)
{
RadioButton rb = new RadioButton();
rb.AutoSize = true;
rb.Text = choice.InnerText;
rb.Top = top;
rb.Left = 10;
top += rb.Height + 5;
pnl.Controls.Add(rb);
if (!fc) // check first item.
{
fc = true;
rb.Checked = true;
}
}
}
if (type == "mct" || type == "txt")
{
TextBox tb = new TextBox();
tb.Multiline = true;
tb.Width = 500;
tb.Height = 250;
tb.Top = top;
tb.Left = 10;
pnl.Controls.Add(tb);
top += tb.Height + 5;
}
pnl.Height = top;
this.Controls.Add(pnl);
form_top += pnl.Height + 10;
}
this.VerticalScroll.Value = 0;
this.save_btn.Top = form_top;
}
을 : 당신은 내가 할 시도하고있는 무슨의 명확한 아이디어를 얻을 수 있도록 여기에
코드입니다 ?