dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB
Expertise: Intermediate
Jan 25, 2006

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Using a Default Button and a Multiline Text Box on the Same Form

Suppose you have a button that uses a Default property (set to true) and are editing text in a multiline text box on the same form. When you press the enter, the button's click event fires rather than having a new line added to the text box.

Placing the following code into your click event on the default button on your form enables you to use a default button and a multiline text box on the same form. Basically, this code checks which control has the focus—if it's a multiline textbox, the code cancels the button's click event. You then have to send a newline to the text box manually.


Private Sub cmdOK_Click()
    Static ignoreClick As Boolean
    
    If ignoreClick = False Then
        If TypeOf ActiveControl Is TextBox Then
            If ActiveControl.MultiLine = True Then
                SendKeys vbCrLf
                ignoreClick = True
                Exit Sub
            End If
        End If
    Else
        ignoreClick = False
        Exit Sub
    End If
    
    ' normal code for the OK button would go here...

End Sub
Valpied Adam
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date