Author : Ulysses R. Gotera
Date Submitted : 1/8/2006
Category : Other
Compatibility : .NET
This code has been accessed 2633 times.
Task : C# - Library 1.0; Highlights a control and transfers the focus on the next control
Declarations
Code
using System;
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 : urgotera@gmail.com
/// 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 : urgotera@gmail.com
// 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 : urgotera@gmail.com
// URL : http://www.friendster.com/profiles/urgotera
// **************************************************
//
if (e.KeyChar == (char)13)
SendKeys.Send("{TAB}");
}
}
}