Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

Iam stuck with this issue for quite some time. I have a button control in a vb.net winform. I want to set focus on this button for which i have used the btnSave.Select(), but this function sets the focus on the button without displaying the dashed rectangle around the button. How can i create dashed rectangle around a button control programatically? Please help. This is really urgent!


Thanks & Regards,
Girish
Posted

Hi,

Try btnSave.Focus() instead of btnSave.Select()

If it doesn't work please have a look on this link
Button Control

Regards
Ankit
 
Share this answer
 
v3
Comments
Wayne Gaylard 15-Apr-11 4:54am    
snap!
papfan 15-Apr-11 12:36pm    
Sorry btnSave.Focus() doesnt work since i have tabindex set in the form. btnSave.Select() works , it displays the blue border, but not the dashed rectange. My requirement is to display the blue border and the dashed rectangle around the button once the btn.Select() method is called.
Try btnSave.Focus().
 
Share this answer
 
It's not Select, it's Focus.

You only need to draw a dashed rectangle if you custom-draw your Button, for example, in your custom control class.

One class you can use is System.Windows.Forms.ButtonRenderer. This class is the rendered, it just draw using the Graphics instance, but it renders the whole button at once, not its separate elements.

If you want a separate elements, use System.Windows.Forms.ControlPaint. You may want to use System.Windows.Forms.ControlPaint.DrawGrid for your dotted rectangle. There are many other useful methods.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900