|
Hi to all...
I have a situation where different combinations of event-handlers must be assigned on-the-fly to the Click event of button control.
For example, "button1.click" might need to run "eventHandlerA" and/or "eventHandlerB" and/or "eventHandlerC".
It is easy to assign/de-assign them with "this.myButton.click += new System.EventHandler(eventHandlerX)" and "this.myButton.click -= new System.EventHandler(eventHandlerX)", but I'd like to be able to know which event handlers are active at any given time (and in which order), i.e. something like "foreach (eventHandler in this.myButton.click.eventHandlers) {get the name of the function handling the event}".
In other words, is it possible to enumerate, at run time, the event handlers associated with a given event?
Thanks to all...
JPeraita
|
|
|
|
|
You can do it from inside the class that declared the event, but not from other classes.
The reason is that inside the declaring class, the event is simply a delegate , so you just call its GetInvocationList method to get a list of "subscribers".
However, the event keyword exists partly so you can't do this. Otherwise, any code could get a list of delegates for a certain event and invoke them (whether or not the event in question actually occurred), thereby taking control from the class that delcared the event in the first place.
In your case, you could derive from Button and expose a property that returns all the subscribers to the click event.
Charlie
if(!curlies){ return; }
|
|
|
|
|
A colleague of mine is using Office 2003, installed form a different CD than my Office 2003. We built our solution on his machine this week since my machine was acting up and I need to re-install Windows. The build wouldn't work when building on his machine since it seems like his Office.dll and my Office.dll are two different things! Did MS change the interface between the two minor version changes? He is running a SLIGHTLY older version of Office 2003.
Just want to know if anyone else has had this issue? And if possible - a resolution. I am desperate since our client is not in the best of moods because of this.
modified 30-Aug-22 21:01pm.
|
|
|
|
|
Now we have another problem. When we deploy to our client, the program fails to create a type initializer (whatever that may mean coming from an exception) and dies. The client has MSO2003 installed on their machines and all the dependencies have been copied into their build directory.
What could the cause of this be? The client is very annoyed at the fact that "our" software doesn't work.
modified 30-Aug-22 21:01pm.
|
|
|
|
|
I often find code like this just above a class,sub ,function, property, etc..
I would like to learn what this is used for how do i know what to put here and why? These are just an example but I have seen different code here
<br />
<LocalisableDescription("BlendFill.StartColour"), <br />
Category("Appearance")><br />
<br />
<Editor(GetType(VBPowerPack.Design.BlendFillEditor), GetType(System.Drawing.Design.UITypeEditor)), <br />
TypeConverter(GetType(VBPowerPack.BlendFillTypeConverter)), <br />
Serializable()> _<br />
<br />
<System.Diagnostics.DebuggerNonUserCode()>
Thanks
|
|
|
|
|
|
I created a simple user control in C# which has a button in it.
//DemoControl.cs
namespace DemoControl
{
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 16);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// UserControl1
//
this.Controls.Add(this.button1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(608, 248);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.UserControl1_MouseMove);
this.ResumeLayout(false);
}
#endregion
}
}
The i created an MFC ActiveX control to host the C# control
//HostCtrol.cpp
int CMfcHostCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
AfxEnableControlContainer();
DemoControl::UserControl1* pcal = new DemoControl::UserControl1();
CComPtr<iunknown> spunkControl;
spunkControl.Attach((IUnknown*)System::Runtime::InteropServices::Marshal::GetIUnknownForObject(pcal).ToPointer());
CRect rectPlaceHolder;
GetClientRect( &rectPlaceHolder );
m_ctrl.Create(spunkControl, WS_VISIBLE | WS_TABSTOP, rectPlaceHolder, this, 0);
return 0;
}
where m_ctrl is CWinFormsControlWnd class which i downloaded from the MSDN Magazine at http://msdn.microsoft.com/msdnmag/issues/03/03/WindowsForms/default.aspx
It works great, but the hosting application stuck when i press the button.
Does anyone knwos whats wrong?
Amir.
Amir Harel
|
|
|
|
|
Hiya I have a script that I want run when installing my app. This scripts adds my database table.
How do I do this??
Thanks.
|
|
|
|
|
Hi All
Ive written a portal mobile portal in vb.net that I want to secure to only authenticated users. I am having great difficulty doing this, as when I test in the nokia wap simulator 4.0 (most of the users will have nokia browsers) I cant seem to store any state.
When I authenticate the user, NMB 4.0 doesnt reflect the persisted information. THe web config file is set to not use cookies and the state is persisted if I test it with a an actual nokia 6230(GPRS), the open wave simulator and also normal IE browser. Any Help is appreciated.
(details of the authentication Im using is below):
Dim username As String = "RyanMalone"
FormsAuthentication.Initialize()
Dim strRole As String = AssignRoles(username)
'The AddMinutes determines how long the user will be logged in after leaving
'the site if he doesn't log off.
Dim fat As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, _
username.ToString, DateTime.Now, _
DateTime.Now.AddMinutes(1), False, strRole, _
FormsAuthentication.FormsCookiePath)
Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, _
FormsAuthentication.Encrypt(fat)))
Session("Telco") = "Optus"
|
|
|
|
|
Hello people,
My company has a set of COM components that all have the same interface, so we use CATID's to allow the user to select which component to use.
I have succesfully wrapped one of our components ina .NET wrapper using the MS tools, and it works fine from C# etc. However, I cannot find a .NET equivilent of the CATID mechanism to categorise a set of comnponents with the same I/F.
Can anyone point me in the right direction? I know there is a recent article of actually using CATID in .NET, but I was wondering what the .NET systme would use natively.
TIA
JamesH
|
|
|
|
|
Hi!,
i hava a problem with a web service: the client signs an xml document using infopath and sends it to the server. I try to verify ir using checksignature method but always returns false!!!!!!!!
maybe the error is that i sign the document with infopath.
please help!
|
|
|
|
|
how come i cant override the public virtual method 'Clear()' of the System.Collections.CollectionBase class?
when im trying to override it im getting that error:
"C:\Documents and Settings\Roy\My Documents\Visual Studio Projects\WebEngine\Class1.cs(49): 'Goblineye.Projects.WebEngine.EditorCollection.Clear()' : cannot override inherited member 'System.Collections.CollectionBase.Clear()' because it is not marked virtual, abstract, or override"
however, the method does declared as virtual...
here's the method declaration (provided by MSDN):
public virtual void Clear();
You can spot it right here:
CollectionBase's Clear() Method
i would be grateful for any help.
|
|
|
|
|
At the bottom of the page is a link to tell microsoft about it. If your mail client supports it then the link will open a new email with the subject line appropriately populated. Write your comments in the body of the email.
If you want to override the behaviour of the Clear() method then I suggest you override OnClear() [which is called before Clear() ] and/or OnClearComplete() [which is called after Clear() ] instead.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I'm working on writing a custom menubar/toolbar set of classes, to replace the standard windows menu bar in my applications. I would like to have a fully custom-drawn, pure C#/.NET coded paint method to draw the popup menus for the menubar. I've run into the little problem of needing the screen DC to be able to properly draw the popup menu outside the bounds of the menubar control, though.
Is there any way to get the screen DC using GDI+, so I could draw to it as if it were a standard windows control? I remember being able to do this long ago before the days of MFC, but I havn't tried since. I havn't had much luck finding any documentation on how in the MSDN help, nor by browsing around the articles here on CP.
Any help is greatly appreciated...
|
|
|
|
|
Try calling GetDC using WIN32 interop.
Like this:
Step 1. int hdc = GetDC (0) // Gets the screen DC
Step 2. Get a graphics object from the DC and draw
Step 3. Dispose the graphics object and call releaseDC like this
ReleaseDC (hdc, 0)
Thanks
Shafqat Ahmed
admin@shiplu.com
|
|
|
|
|
Thanks for the reply. I assume the GetDC() function is in gdi32.dll? I use C#, not C++, so I have to DllImport it to use it.
|
|
|
|
|
hi there
i am trying to connect dataset true crystal reportos in visual dot net framework 2003
when i am defining the reporot every thing is o.k
but when i am trying to see the report in the Form
i have a problem
before the report is up i am geeting a login Form
its called database login
Server name :
DataBase :
LogIn ID :
Password :
what do i need to write in this Form & i dont want this Form every time that i want to see the report
how can i pass it or put it in code ??
i am on c# my Db is Oledb (Accses)
thanks ....
|
|
|
|
|
Hi All
I am trying to build a Debug version of Win32 DLL under Dot Net 2003 . I link to a Release version of Win32 DLL not using MFC built under the Visal Studio 6.0 ,
I always get the above mentioned error with Unresolved external symbols.
Anyway, I can fix it.
I can build release version successfully.
Thanks
Sankar
|
|
|
|
|
Hi all
I'm building a C# application to run on a PocketPC. What I want to do is be notified when the device is docked. This way I can connect to our server and refresh some internal information. The info doesn't live on the desktop machine, so it has to be retrieved via a TCP connection.
I've had a good look through the MSDN examples, and I'm feeling a little lost and confused. It speaks about a function called CeRunAppAtEvent which appears to be precisely what I want. But I don't know how to get this running successfully in the C# app.
Any help or even pointers would be greatly appreciated.
Thanks in advance
Andre
|
|
|
|
|
hi all... i need help... here's my problem.. i need to open internet explorer in .net cf so that it will link to some page.. unfortunately .net cf dosent' support this function (System.Diagnostics.Process.Start("http://www.google.com/")..
i've searched far and wide for and answer and here's the nearest solution i found..
http://www.dotnet247.com/247reference/msgs/18/93902.aspx
he has a simmiliar problem with me and he solved it using some code there .. which i don't really understand cause i'm a junior programmer.. anyone kind enuf to plz test the code for me and do a sample working program for me plz?
send it to chrisleong18@yahoo.com ok?
thanks in advance... i really need to do this.. help ...
prozio
|
|
|
|
|
Hi,
Can anyone plz tell the fix for following problem !!
I'm getting an error while opening a report thru .net,
it says "Fail to render the page".
The error i'm getting is only for the first page.
Second page is displayed properly !!
The report runs nicely with Crystal Report s/w.
Plz do tell the fix ... It's urgent
Thanks in anticipation
|
|
|
|
|
Hi, everybody,
Rightnow, I installed my Visual Studio .NET 2002 in my pc running Windows XP with .NET framework 1.0.
My question is : If I download .NET Framework 1.1 and install it on my pc, does my vs 2002 use the new framework 1.1? If yes, how can I check it?
Thanks in advance!!
Alan Shen
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
For every version of the .net framework, Microsoft releases a new version of vs.net.
- Visual Studio.NET 2002 -> .NET framework 1.0
- Visual Studio.NET 2003 -> .NET framework 1.1
- Visual Studio.NET 2005 -> .NET framework 2.0
To answer your question: You can't use an older version of visual studio to work with a newer version of the framework.
|
|
|
|
|
ZippyV wrote:
For every version of the .net framework, Microsoft releases a new version of vs.net.
I think a more accurate statement would be:
So far for every version of the .net framework, Microsoft releases a new version of vs.net
This may or may not continue to be true.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi All,
I have data (files and folders) into sql2000 and want to display into windows explorer as drive(virtual drive).
if anybody have already done this type of work. please let me know asap.
Thanks & Regads,
Dinesh
Dinesh Chandra Porwal
Sr.Software Engineer
|
|
|
|