本文介绍了在运行时添加组合框的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是编程的新手,这是我的代码 int c = 0 ; private void button1_Click_1( object sender,EventArgs e) { ComboBox txtRun = new ComboBox(); txtRun.Name = txtDynamic + c ++; txtRun.Location = new System.Drawing.Point( 30 ,18 +(30 * C)); this .Controls.Add(txtRun); panel1.Controls.Add(txtRun); } i正在制作一个动态添加到Windows窗体上的组合框,它将组合框一个接一个地放置,我使用面板,以便其他控件不能通过添加运行时控件来实现,这里的问题是当我单击按钮并向面板添加新的组合框时,它成功添加并且我的面板大小为所以当我添加5个组合框时,我必须滚动查看第5个组合框。(滚动面板而不是表格),主要问题仍然存在,当我滚动并且焦点在第5个组合框上,然后当点击按钮添加新的组合框时,新组合框的位置是我之前做过的组合框的位置的两倍,所以它看起来很奇怪,那个五个组合框是按顺序排列的,而第六个是在那个下方较大的距离,如何解决这个问题,请帮助 抱歉我的英文不好解决方案 I am newbie to programming, this is my codeint c = 0; private void button1_Click_1(object sender, EventArgs e) { ComboBox txtRun = new ComboBox(); txtRun.Name = "txtDynamic" + c++; txtRun.Location = new System.Drawing.Point(30, 18+(30*c)); this.Controls.Add(txtRun); panel1.Controls.Add(txtRun); }i am making a combobox which is added dynamically on a windows form, it places the combobox one after the other, and i used panel so that the other control cannot be effected by the adding of runtime control, here the problem is when i click the button and add new combobox to the panel, it adds successfully and my panel size is so when i add 5 combobox then i have to scroll to see the 5th combobox.(scroll the panel not the form), and the main problem persist here, when i scroll and the focus is on 5th combobox and then when click on button for adding new combobox then the location of the new combobox is double the location of combobox which i have made earlier so, it looks odd, that five of combobox are in sequence and the 6th one is at the larger distance below that, how to solve this problem, plz helpsorry for my bad english 解决方案 这篇关于在运行时添加组合框的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!