473,322 Members | 1,496 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,322 software developers and data experts.

How to call an event from another event

Hello,

i have some textboxes on my form and want write a generalized code which could change the color of the textboxes on focus.
Also how can i call an event from another event(how to call a leave event on a click of a button).

i am using C#.
Mar 7 '07 #1
4 2085
Hello,

i have some textboxes on my form and want write a generalized code which could change the color of the textboxes on focus.
Also how can i call an event from another event(how to call a leave event on a click of a button).

i am using C#.
hi it is not a big problem.

1. just change the color u want to show once the focus is in the text box
that should written in the MouseEnter Event.
private void txtBox_MouseEnter(object sender, System.EventArgs e)
{
//set the color here. since u want to know the focus can uesd flag

}

2.then set the color once the focus out from the text box in the MouseLeave event
That should be the default color
private void pbUpDown_MouseLeave(object sender, System.EventArgs e)
{
//here sholud set default color
}

I think this is what u want
bi
madushan thilina
Mar 7 '07 #2
hi it is not a big problem.

1. just change the color u want to show once the focus is in the text box
that should written in the MouseEnter Event.
private void txtBox_MouseEnter(object sender, System.EventArgs e)
{
//set the color here. since u want to know the focus can uesd flag

}

2.then set the color once the focus out from the text box in the MouseLeave event
That should be the default color
private void pbUpDown_MouseLeave(object sender, System.EventArgs e)
{
//here sholud set default color
}

I think this is what u want
bi
madushan thilina
The code u have suggested is for each textbox in the form...... i want a bit generalised method ie;without actually writting code for each control.....something dynamic.
i am able to get the no of textboxes on the form(dynamically) and can clear all on a click of a bttn.... but not able to fire another event from an event
This piece of code is what i am using

// Initialization code is designer generated and contained
// in a separate file using the C# 2.0 support for partial
// classes.
InitializeComponent();
}
// The event handler for the button click event.
private void cmdProcessAll_Click(object sender, System.EventArgs e)
{
ProcessControls(this);
}
private void ProcessControls(Control ctrl)
{
// Ignore the control unless it's a textbox.
if (ctrl.GetType() == typeof(TextBox))
{
ctrl.Text = "";
}
// Process controls recursively.
// This is required if controls contain other controls
// (for example, if you use panels, group boxes, or other
// container controls).
foreach (Control ctrlChild in ctrl.Controls)
{
ProcessControls(ctrlChild);
}
}
Mar 7 '07 #3
Frinavale
9,735 Expert Mod 8TB
The code u have suggested is for each textbox in the form...... i want a bit generalised method ie;without actually writting code for each control.....something dynamic.
i am able to get the no of textboxes on the form(dynamically) and can clear all on a click of a bttn.... but not able to fire another event from an event
This piece of code is what i am using
...
Hi there,

I'm not sure if this would help or not but I've found that JavaScript really helps in situations like this....it will relieve your server of a lot of unnecessary traffic too.

I suggest writing a global function that you can call on your pages that will register the JavaScript for you. You'd still have to go through and make sure that the JavaScript is called by your text box on focus....

You'd have to add something like:

txt_example.Attributes.Add("onfocus", "javascript:changeFocusColour();")

To each of your text boxes so that they call the JavaScript....of course you'd have had to have written the changeFocusColour() JavaScript method as well.

Could this help you at all?

-Frinny
Mar 7 '07 #4
radcaesar
759 Expert 512MB
Use javascript for the first one.

Explain the functionality for the later one in detail.

:)
Mar 7 '07 #5

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

Similar topics

3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
1
by: seash | last post by:
hi friends I need to call an event (private void groupBox4_Enter(object sender, System.EventArgs e)) from an another event (private void Appexit_Closing(object sender,...
5
by: Anand Ganesh | last post by:
Hi All, I need some help. I am sort of not sure how to approach this problem. I have a MAINPROGRAM. This is the core application. I have asked two of my staff to developed two different...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
3
by: Ignacio Machin | last post by:
How can I call an event from another event: I want to call : DropDownList_SelectedIndexChanged in: Page_Load
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.