by Ulysses R. Gotera (9 Submissions)
Category: Miscellaneous
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Tue 1st August 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
C# - Library 1.0; Highlights a control and transfers the focus on the next control
API Declarations
// 1. Create a file called Library.cs.
// 2. Copy the codes and paste it.
// 3. Add Library.cs to your Solution/Project
// 4 In your namespace that you want to use it add:
// using Library;
//
// The author will be placing more generic procedures in the future.
using System.Text;
using System.Windows.Forms;
namespace Library
{
/// <summary>
/// **************************************************
/// Description : Collection of generic modules
/// Author : Ulysses R. Gotera
/// Date Created : Sunday, January 08, 2006
/// Date Modified: <>
/// Version : 1.0
/// Country : Philippines
///
/// E-mail : [email protected]
/// URL : http://www.friendster.com/profiles/urgotera
///
/// Disclaimer : The author is not responsible for any
/// loss or damage of data or application if this is
/// used for business purposes.
/// **************************************************
/// </summary>
public class CustomControls
{
public CustomControls()
{
//
// TODO: Add constructor logic here
//
}
public static void HighLightCtrl(Control p_objectCtrl)
{
// **************************************************
// Description : Higlights a selected text in a TextBox
// or ComboBox control.
// Author : Ulysses R. Gotera
// Date Created : Sunday, January 08, 2006
// Country : Philippines
//
// E-mail : [email protected]
// URL : http://www.friendster.com/profiles/urgotera
// **************************************************
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;
}
}
}
public static void NextControl(System.Windows.Forms.KeyPressEventArgs e)
{
// **************************************************
// Description : If the user presses the enter key then
// the focus will be on the next tab index.
// Author : Ulysses R. Gotera
// Date Created: Sunday, January 08, 2006
// Country : Philippines
// E-mail : [email protected]
// URL : http://www.friendster.com/profiles/urgotera
// **************************************************
//
if (e.KeyChar == (char)13)
SendKeys.Send("{TAB}");
}
}
}
No comments have been posted about C# - Library 1.0; Highlights a control and transfers the focus on the next control. Why not be the first to post a comment about C# - Library 1.0; Highlights a control and transfers the focus on the next control.