|
The above code is for C or C++ not C#. Are you sure you are in the right forum?
|
|
|
|
|
it is an ansi c program not c++ .....i think im in the wrong forum my apologies....i dont kno where is the rite forum cause i dont want c++ i want C only
-- modified at 13:33 Tuesday 6th November, 2007
|
|
|
|
|
C++ is the superset of C. If you say you are using C they will be able to help in the C++ forum most likely.
|
|
|
|
|
Hi,
i have a User Control i've created
When a property is changed i like to raise an event
in the Form Hosting The user control
but i also want to pass a value to The Form
i've Done this :
<br />
<br />
public event EventHandler MyVarChanged;<br />
<br />
private void OnChanged(FireEventArgs e) <br />
{<br />
if (MyVarChanged != null)<br />
MyVarChanged(this, e);<br />
}<br />
<br />
and in the Set {} of The property:<br />
if (myVar > 10)<br />
OnChanged(EventArgs.Empty);<br />
in The Form :
<br />
private void userControl11_MyVarChanged(object sender, EventArgs e)<br />
{<br />
}<br />
So Far So Good
but i like to pass a parameter
How Do I continue...
THNKS
Have Fun
Never forget it
|
|
|
|
|
To pass a parameter, don't use EventArgs. Create a new class deriving from EventArgs that contains your information. The call OnChanged(new MySpecialEventArgs(...)) to raise the event and pass parameters to the handlers.
|
|
|
|
|
Yeh i figured that
But Got Stucked
i've created that derived like this :
<br />
public class MyVarChangedEventArgs: EventArgs<br />
{<br />
public bool sState;<br />
<br />
public MyVarChangedEventArgs(bool state) <br />
{<br />
this.sState = state;<br />
}<br />
}<br />
And Changed all other like this :
<br />
if (myVar > 10)<br />
OnChanged(new MyVarChangedEventArgs(true));<br />
public event EventHandler MyVarChanged;<br />
<br />
private void OnChanged(MyVarChangedEventArgs e) <br />
{<br />
if (MyVarChanged != null)<br />
MyVarChanged(this, e);<br />
}<br />
but when i open the
e. in The form i do not see the value
am i missing something
Maybe i did not understood the idea that well
THANK
Have Fun
Never forget it
|
|
|
|
|
You need to either change your event declaration to use your custom EventArgs, like so:
public event EventHandler<MyVarChangedEventArgs> MyVarChanged;
Or you can case the EventArgs in your event handler to your custom EventArgs. Basically, the framework things it's an instance of EventArgs, but actually it's an instance of MyVarChangedEventArgs. The first option is your best bet though.
-- modified at 14:18 Monday 5th November, 2007
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
YEH
I've Got IT
and Changed IT
Again THANKS
Have Fun
Never forget it
|
|
|
|
|
THANKS
U gave my Thy Path
Got it
THANKS A LOT
Have Fun
Never forget it
|
|
|
|
|
Can I suggest that you look at using an EventPool[^]? They are really useful.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Wow,
it Really Goes Deeper
i'll need time to understaned it
But THANKS
it looks intersting but more inportent USEFULL
Have Fun
Never forget it
|
|
|
|
|
HI,
By The way do u have any suggestion how can i write an article Here
i've Got a DLL i coded, for the DataGridViewDateTimePickerColumn
THANKS
Have Fun
Never forget it
|
|
|
|
|
One way to do it is to follow this[^] article and use the Article Submission Wizard or the template zip file. If you use the template, submit it to the editors for upload.
Let me know when it's uploaded and I'll have a read through. Good luck.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I want a CheckBox in the header of a GroupBox that depending upon the state of the check will changed the size of the group box (via animation) and changed the properties (visibility) of the controls in the group box just using XAML.
How can I do this?
<window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" windowwidth="550" windowheight="350">
<groupbox>
<groupbox.header>
<wrappanel>
<checkbox x:name="GetCreate">Get
<textbox>
<textbox>
Thanks!
|
|
|
|
|
How would I go about converting an IntPtr from Delegate.Method.MethodHandle.GetFunctionPointer() back into a delegate in .NET 1.1? I know there is a way to do it in 2.0 using the Marshal class but cannot see how to do it in 1.1.
I think I will have to use unmanaged code to do it but any pointers on how would be good, I'm not new to C# or C++ but not sure how to go about this.
Thanks.
|
|
|
|
|
HYave you looked at Delegate.CreateDelegate? There's an overload that takes a RuntimeMethodHandle, which in turn wraps an IntPtr. The result of a CreateDelegate can be cast to some delegate type.
|
|
|
|
|
Thanks for the reply but I can only see an overload which takes a MethodInfo and there doesn't seem to be a way to create one from an IntPtr. Is there any other way to do this?
|
|
|
|
|
I misspoke:
Delegate.CreateDelegate(type, System.Reflection.MethodInfo.GetMethodFromHandle(someRuntimeMethodHandle));
The runtime method handle takes an IntPtr.
|
|
|
|
|
It doesn't seem to take an IntPtr, I get 'Cannot convert from System.IntPtr to System.RuntimeMethodHandle' with or without a cast. The .Value property of a new RuntimeMethodHandle is readonly too so I cannot set it that way either.
|
|
|
|
|
Right, you can't cast it. I'm not sure how to generate a RuntimeMethodHandle, then, on your own. You'd need to generate one and pass it to the MethodInfo.GetMethodFromHandle method. I'm not sure how to do that, or even if we're barking up the right tree.
|
|
|
|
|
I have a problem changing the Content property from a custom control in response to an event.
I have window1 as main and two custom controls. Content is set to first custom control wich has a button.
1.I wish when i push that button to set window1's Content property to the second control.
2.I wish when pressing "Escape" key for example while second custom control is in window1's Content to return the first custom control to window's Content property.
EDIT-solved: to get a handle:
IntPtr windowHandle = new WindowInteropHelper(
Application.Current.MainWindow).Handle;
or
IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
or
make use of the routed events
or
Application.Current.MainWindow.Content
-- modified at 18:59 Tuesday 20th November, 2007
|
|
|
|
|
wolfshad3 wrote: I wish when i push that button to set window1's Content property to the second control.
Set up an event handler for the button's click event. In that handler, set window1.Content = secondControl
wolfshad3 wrote: I wish when pressing "Escape" key for example while second custom control is in window1's Content to return the first custom control to window's Content property.
Set up an event handler for the form's key down event. In that handler, check if the key is ESC, and if so set window1.Content = firstControl
|
|
|
|
|
Thanks, i dreamed up that i should use a routed event too during last nights sleep.
EDIT: to get a handle:
IntPtr windowHandle = new WindowInteropHelper(
Application.Current.MainWindow).Handle;
or
IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
|
|
|
|
|
Hy!
It is possible to read how many unread mails have in inbox yahoo mail?
thx
|
|
|
|
|