473,471 Members | 4,629 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Custom Textbox AutoTab

I built 3 textbox classes. The auto tab does not tab to the next control in
the tab list. No errors, and the code steps through
"this.SelectNextControl(this, true, true, true, true);".

What is the code missing, so the auto tab will go to the next control in the
tab list when the max length value is reached?

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
}

class ClassTextBoxNum : ClassTextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) &&
!Char.IsControl(e.KeyChar))
{
e.Handled = true;
}
base.OnKeyPress(e);
}

}

class ClassTextBoxNumTab : ClassTextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true;
}
base.OnKeyPress(e);
}

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);

if (this.Text.Length == this.MaxLength)
{
this.SelectNextControl(this, true, true, true, true);
}
}

}

Dec 20 '05 #1
2 6043
Hi Cadel,

Thanks for your post.

I am not sure I understand your problem context very well. Can you give
some more detailed description on it?

Currently, after reviewing your sample code snippet, I think the problem
may be that the this.SelectNextControl(this, true, true, true, true)
statement does not work in ClassTextBoxNumTab, yes?

To resolve this problem, I can provide 2 solutions:
1. Use ProcessDialogKey(Keys.Tab) method to simulate the tab key function
2. first find the parent form, then inovke Form.SelectNextControl method.

Sample code snippet listed below:
class ClassTextBoxNumTab : ClassTextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
{
e.Handled = true;
}
base.OnKeyPress(e);
}

protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);

if (this.Text.Length == 20)
{
//this.ProcessDialogKey(Keys.Tab); // this is the first solution
this.FindForm().SelectNextControl(this, true, true, true, true); //this
is the second solution
}
}
}
Note: I modified this.MaxLength to 20, so that we can achieve the
limitation ASAP.

These 2 solutions works well on my side. Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 21 '05 #2
Hi Cadel,

Does my reply make sense to you? Is your problem resolved? Please feel free
to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 27 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryan Joseph So | last post by:
Hi, I've been searching the web for custom textbox control that doesn't inherit from Windows textbox control but cannot find one. I've been trying to make my own custom textbox but I just dont...
0
by: Steve R | last post by:
I've built a composite web custom control with a lot of child controls. I assigned ToolTip values to some of these controls. The ToolTip pop-ups were working fine until I monkeyed with the order...
1
by: Sanjay Pais | last post by:
I built a custom control for all the basic web.ui.controls like textbox, label, checkbox etc etc. I added my custom attribute called ApplySecurity to the html in the page. However, when I cycle...
2
by: keithtracypierce | last post by:
1)Access2003, beating my head against the wall, every other iteration is "can't find macro Upshift" followed by carefully verifying that no blank properties have been entered. Making NO changes at...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
0
by: rn5a | last post by:
A custom control is derived from the WebControl class & encapsulates a TextBox & a Button. When the Button is clicked, the user is shown the JavaScript confirm dialog with the 'OK' & 'Cancel'...
2
by: Michal Valent | last post by:
I would like to fire some custom server control event before Page_Load event like this (from the trace of an aspx page) : Trace Information Category Message From First(s) From Last(s) aspx.page...
7
by: adiel_g | last post by:
Hello Everyone, I created a custom control. On the CreateChildControls, I added a textbox to the control as follows: // TextBox TextBox txtValue = new TextBox(); txtValue.ID = "txtValue"; ...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.