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

calling a control at runtime

SL
I have a packaged control that I want to work off a button. How do I call
it from btn_click()

For example:

Private Sub controlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles controlA.Click
End Sub

Private Sub btnControlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnControlA.Click
' here I want to call controlA_Click
End Sub

Any help would be appreciated.

S

Nov 20 '05 #1
3 982
"SL" <no**@earthlink.net> wrote in
news:uw**************@TK2MSFTNGP09.phx.gbl:
I have a packaged control that I want to work off a button. How do I
call it from btn_click()

For example:

Private Sub controlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles controlA.Click
End Sub

Private Sub btnControlA_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnControlA.Click
' here I want to call controlA_Click
End Sub


controlA_Click(me, nothing)

Or you can use a RaiseEvent controlA.click

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2

"SL" <no**@earthlink.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Private Sub btnControlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnControlA.Click
' here I want to call controlA_Click
End Sub


Lucas gave you the direct answer. I'll give you the stock answer that it's
generally considered bad practice to call control events directly. If the
code executed in an event handler may need to be called outside that event
handler, it's recommended that you put the code in a separate procedure and
call that procedure, both from inside the handler and wherever else you need
to call it. In this case, your sample code would look like:

Private Sub controlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles controlA.Click
ProcessControlA()
End Sub

Private Sub btnControlA_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnControlA.Click
ProcessControlA()
End Sub

Everything you used to have in controlA_Click needs to be moved to
ProcessControlA().
Nov 20 '05 #3
Hi SL,

You have in VBNet a lot of possibilities, the one from Lucas is very nice by
instance.

I myself use often call the event with
method(nothing, nothing), and then because it is nothing I know it is not
sended from an control.

However when you google this newsgroup on this you find a lot of methods,
there are at least 4 and nobody in this newsgroup could really prove why the
one was better than the other. Mostly a matter of taste.

I hope this helps?

Cor
Nov 20 '05 #4

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

Similar topics

15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: JezB | last post by:
In my Page_Load event of all my web app Pages and UserControls I instantiate the same library class "TextResources" (to take care of reading presentation text strings from localizable resource...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
7
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: fillic2002 | last post by:
Hi I have a query related to the VS2005 usercontrol. As i have two different usercontrol in a single master page say uc1 and uc2. Now i am calling a function of uc1 from uc2. what is the best...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
1
by: vanajasethu | last post by:
Hi all, I am working in dotnet remoting using dotnet framework 2.0 in windows xp. I am hosting the remote object in iis using http channel and binary formatter and registering the object in...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: pinky22 | last post by:
I am calling SSIS package from a .Net windows UI. Both SSIS & .Net app are created in 2008. The SSIS package is stored in file system. When I ran .Net app I got error- The package failed to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...

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.