VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Highlight or selects the text in a text box or combo box

by Ulysses R. Gotera (9 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Sat 1st July 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Highlight or selects the text in a text box or combo box

API Declarations


.Net Language: C#

The code is created in Visual Studio's IDE. Open your Visual Studio or a text editor and copy and paste the code below.

Rate Highlight or selects the text in a text box or combo box



{
// **************************************************
// Description  : Higlights a selected text in a TextBox
//    or ComboBox control.
// Author       : Ulysses R. Gotera
// Date Created : Sunday, January 08, 2006
// Country      : Philippines
// **************************************************
int intLength; string strTemp; 
TextBox objectTxtBox;
ComboBox objectComboBox;
//
if (p_objectCtrl.CanSelect) 
{
if (p_objectCtrl is TextBox)
{
objectTxtBox = (TextBox) p_objectCtrl;
objectTxtBox.SelectionStart = 0;
strTemp = objectTxtBox.Text.Trim();
intLength = strTemp.Length;
if (intLength > 0) 
objectTxtBox.SelectionLength = intLength;
}
//
if (p_objectCtrl is ComboBox)
{
objectComboBox = (ComboBox) p_objectCtrl;
objectComboBox.SelectionStart = 0;
strTemp = objectComboBox.Text.Trim();
intLength = strTemp.Length;
if (intLength > 0)
objectComboBox.SelectionLength = intLength;
}
}
}


Download this snippet    Add to My Saved Code

Highlight or selects the text in a text box or combo box Comments

No comments have been posted about Highlight or selects the text in a text box or combo box. Why not be the first to post a comment about Highlight or selects the text in a text box or combo box.

Post your comment

Subject:
Message:
0/1000 characters