我做的程序Form上有一个Panel,Panel里面放了几个ListBox,程序启动后,焦点自动落到第一个ListBox上(该ListBox的TabIndex为1),此时ListBox上有一个虚线框.
我用代码段: ListBox listbox = (ListBox)sender;
listbox.Parent.Focus();
主要想让ListBox的Prarent也就是Panel得到焦点,但是始终不行,这是为什么?有没有什么解决方法,能让焦点不要落在ListBox上?谢谢!
我用代码段: ListBox listbox = (ListBox)sender;
listbox.Parent.Focus();
主要想让ListBox的Prarent也就是Panel得到焦点,但是始终不行,这是为什么?有没有什么解决方法,能让焦点不要落在ListBox上?谢谢!
要让焦点不在ListBox1上,只能把焦点设置到Parent的其它的子控件上,比如按钮或文本框等。
this.ActiveControl=this.button1;或设置要得到焦点的控件的TabIndex为0.
所以修改TabIndex就行了