473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ 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.SelectNex tControl(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(KeyP ressEventArgs e)
{
if (!Char.IsDigit( e.KeyChar) &&
!Char.IsControl (e.KeyChar))
{
e.Handled = true;
}
base.OnKeyPress (e);
}

}

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

protected override void OnTextChanged(E ventArgs e)
{
base.OnTextChan ged(e);

if (this.Text.Leng th == this.MaxLength)
{
this.SelectNext Control(this, true, true, true, true);
}
}

}

Dec 20 '05 #1
2 6056
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.SelectNext Control(this, true, true, true, true)
statement does not work in ClassTextBoxNum Tab, yes?

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

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

protected override void OnTextChanged(E ventArgs e)
{
base.OnTextChan ged(e);

if (this.Text.Leng th == 20)
{
//this.ProcessDia logKey(Keys.Tab ); // this is the first solution
this.FindForm() .SelectNextCont rol(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
2243
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 know how to do it. Can anyone out there help me out how to make one. Just a simple textbox so i could understand how to make it. This is my first time to make custom control so i still have much to learn. Thanks.
0
1512
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 I am rendering the controls. I had to do this so that the control rendered properly when a developer drags it from the toolbox onto the page. Any ideas? Below is the meat of the code from my user control. The remainder is private methods.
1
1702
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 through the controls on the page using this code, I cant seem to be able to access the Attribute collection. However, if I were to add the tag to a regular TextBox, the Attribute is available. My recursive function looks like this:...
2
3915
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 all, sometimes the message goes away, sometimes not. Any clues? 2)The other headbeating iterations are due to no joy when trying to allow T,F,Blank in a 1-character field, with AutoTab enabled. InputMask:>C;; DefaultValue:
1
3225
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' & 'Cancel'). Till this point, no problem. Initially, the TextBox is empty. The Button has a property named 'ConfirmMessage' so that the developer using this custom control can modify the question in the confirm dialog. If the user clicks 'OK', I want the...
0
1389
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' buttons. If the user clicks 'OK', the TextBox gets populated with 'true' & if 'Cancel' is clicked, the TextBox gets populated with 'false'. Note that when the user first comes to the ASPX page that uses this custom control, the TextBox is empty. This...
2
2737
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 Begin PreInit aspx.page End PreInit 5,38454603734274E-05 0,000054 aspx.page Begin Init 8,96405962016187E-05 0,000036 aspx.page End Init 0,00072941040948794 0,000640 aspx.page Begin InitComplete 0,000772971258380746 0,000044
7
3081
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"; protected override void CreateChildControls() { // Add the control to the form
4
1837
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" %> In another custom web user control, I use this web control: <%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub" TagPrefix="mb"
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8862
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.