473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

event control

hi,
i m new in c sharp. I m working in a project in which there are 4 textbox , which are to filled serially. If the user filled the wrong value in first textbox , a message should be displayed and the control should remain in the same textbox. or in other words user should be forced to fill the boxes serially. i hope i explained the problem.
so,plz, help me in getting out of this prob.
thanx
Oct 31 '09 #1
7 2053
tlhintoq
3,525 Expert 2GB
Use the .Enabled property to disable the other textboxes
.Enabled = false;

When the user has given a proper answer to the first textbox you can disable it, enable the second and use the .Focus property to put the cursor in that box.
Oct 31 '09 #2
thanx for the previous reply.
but using .Focus(textbox2.focus in textbox1) gives error Error "Cannot assign to 'Focus' because it is a 'method group' "
Oct 31 '09 #3
tlhintoq
3,525 Expert 2GB
Right.
It is a method. The error tells you this.
Methods take parameters within parentheses.
Expand|Select|Wrap|Line Numbers
  1. textbox2.focus();
Oct 31 '09 #4
hi,
i have 4 textboxes in my project.
if a wrong entry is made in a textbox, then as soon as i move to nexttextbox a error box is displayed. and all the entries should be made serially.
i used enabled key bt in that case mouse cant be used.
then i used foll code:
Expand|Select|Wrap|Line Numbers
  1. private void textBox1_Leave(object sender, EventArgs e)
  2.         {
  3.  
  4.                 text1();               
  5.                 label6.Visible = false;
  6.                 button4.Enabled = true;
  7. }
  8. public void text1()
  9.         {
  10.             if (textBox1.Text == "")
  11.             {
  12.                  System.Windows.Forms.DialogResult result = MessageBox.Show(this, "Enter tttValue between[ 1 to 3000]", "Start Value error", MessageBoxButtons.OK,
  13.                     MessageBoxIcon.Error);
  14.                 if (result == System.Windows.Forms.DialogResult.OK)
  15.                     textBox1.Focus();             
  16.                           return;
  17.             }            
  18.                 s = float.Parse(textBox1.Text);
  19.                 if (!(s > 0 && s < 3000))
  20.                 {
  21.                                         System.Windows.Forms.DialogResult result = MessageBox.Show(this, "Enter Value between[ 1 to 3000]", "Start Value error", MessageBoxButtons.OK,
  22.                     MessageBoxIcon.Error);
  23.                     if (result == System.Windows.Forms.DialogResult.OK)
  24.                         textBox1.Focus();                    
  25.                     return;
  26.                 }
  27.  
  28.         }
but in this case if i move from textbox2 to textbox1 its not allowing me due to leave func.
so is there any other way i can do that
Nov 4 '09 #5
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Nov 4 '09 #6
tlhintoq
3,525 Expert 2GB
if i move from textbox2 to textbox1 its not allowing me due to leave func.
and all the entries should be made serially.
Well which is it? If all entries are to be made in sequence then you aren't allowing people to back up from textbox2 to textbox1.

if you are allowing people to do so but only under certain conditions then you need to check for those conditions and if they are met, then re-enable textbox1.
Nov 4 '09 #7
tlhintoq
3,525 Expert 2GB
Also... You already a thread started for this question. There was no reason to start a second one for the same issue/problem. I have merged the two threads. In the future please keep to the basic guide lines of "One thread per issue/One issue per thread."
Nov 4 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
4
by: Anatoly | last post by:
Put any control on web page. create Init event for ths control. Write Response.Write("here") inside this event. Compile\build\run. I never saw "here" string appear on web page. Why???
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
1
by: Jordan S. | last post by:
I'm just wondering if this would work. Please note that I'm not asking *how* to raise events. I'm clear on that. What I'm not clear on is the sequence in which events are raised by custom controls...
4
by: tshad | last post by:
I am just getting started with events and had a couple of questions on why they do what they do. If you have a textbox and you want to handle an event you can just do: ...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
1
by: chandhrakv | last post by:
Hi experts, Can any one please respond with the resolution. Machine: WIN2K3, ASP.NET application, .NET 2.0 with June 2007 hotfix installed recently. Facing daily 1000 errors with the same type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.