• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Cancelling the Default button at run time -- VB.NET

Depending on the conditions, I want to change a button from being the Default button to not having a Default button at all.  I set the default button using this code:  
Me.AcceptButton = btnSearch
I tried cancelling this button with this code:
Me.AcceptButton = Nothing

but it still remains the default button.

Any suggestions?

Thanks.
0
lplasc
Asked:
lplasc
1 Solution
 
VBRocksCommented:
Try programmatically setting the focus to another control after you set it to nothing:

        Me.AcceptButton = Nothing
        Me.TextBox1.Focus()

0
 
Thunder724Commented:
Maker sure the DialogResult is set to NONE on the button.

btnSearch.DialogResult = Windows.Forms.DialogResult.None
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now