|
Sorry, but one can't understand what you want.
Maybe you can post the code that isn't working?
Failure is not an option - it's built right in.
|
|
|
|
|
I'm very sorry -
You are right - i modify my message.
I mean how to declare.
|
|
|
|
|
|
Hello,
Yanshof wrote: is to send events from the some of the user control to this simple C#
Your UserControl should implement an event like this:
public event EventHandler SomethingChanged;
and fire it like this:
if (SomethingChanged!= null)
{
SomethingChanged(this, EventArgs.Empty);
}
Your class, (which holds the instance of the form where the usercontrols are on) should implement a method which returns a list of your UserControl:
private ArrayList GetAllUserControls(Control c, ArrayList allUserControls)
{
if(allUserControls == null)
{
allUserControls = new ArrayList();
}
if(c!=null)
{
if(c.Controls!=null)
{
foreach(Control actControl in c.Controls)
{
YourUserControl actYourControl = actControl as YourUserControl;
if(actYourControl!=null)
{
allUserControls.Add(actYourControl);
}
allUserControls= GetAllUserControls(actControl, allUserControls);
}
}
}
return allUserControls;
}
And call it like that:
ArrayList allUserControls = GetAllUserControls(yourForm, null);
Then you can register the Events.
I would recommend a method which does also the unregistering for your Dispose method.
private void EditEvent(ArrayList allUserControls, bool register)
{
foreach(object o in allUserControls)
{
YourUserControl actYourControl = o as YourUserControl;
if(actYourControl!=null)
{
if(register)
{
actYourControl.SomethingChanged+=new EventHandler(actYourControl_SomethingChanged);
}
else
{
actYourControl.SomethingChanged-=new EventHandler(actYourControl_SomethingChanged);
}
}
}
}
And call it like that (you have to pass the List of UserControls which you got from the GetAllUserControls method):
EditEvent(allUserControls, true);
and in the dispose method:
EditEvent(allUserControls, false);
To find the correct instance in the handler:
private void actYourControl_SomethingChanged(object sender, EventArgs e)
{
YourUserControl actYourControl = sender as YourUserControl;
if(actYourControl!=null)
{
}
}
Yanshof wrote: the C# class will also send events to those user control.
Here I would use a static event in the class.
Hope it helps!
-- modified at 5:21 Tuesday 31st July, 2007
All the best,
Martin
|
|
|
|
|
Can you please explain what do you meed in the line
"YourUserControl actYourControl = actControl as YourUserControl"
?
Thanks.
|
|
|
|
|
Yanshof wrote: YourUserControl actYourControl = actControl as YourUserControl
The 'as' operator tries to cast the Control instance "actControl" to an instance of YourUserControl.
If the cast is not working it will return 'null', an ddoes not throw an exception (like "(YourUserControl)actControl" would do)
All the best,
Martin
|
|
|
|
|
Sorry, there was an error in this line, changed it now!
All the best,
Martin
|
|
|
|
|
I have a windows application in .net 2.0. I use a webbrowser control to display an asp page which is on server. Below the browser control i display an electronic signature.
My requirement is to print this form. I tried to use the memorygraphics class and take the screenshot of the form and draw the image to printer. But this gives me only the part of the form visible on the client area.
The part which is visible on scrolling the form is left. I need the complete form along with the scrolled part.
How do i do this? Can any one help me?
|
|
|
|
|
|
<br />
Button btnPrint = new Button();<br />
btnPrint.Visible = false;<br />
btnPrint.Enabled = true;<br />
btnPrint.Click += new EventHandler(btnPrint_Click);<br />
btnPrint_Click(sender, e);<br />
<br />
...<br />
...<br />
<br />
private void btnPrint_Click(object sender, EventArgs e)<br />
{<br />
String Script = String.Empty;<br />
Script = "<script language='javascript'>";<br />
Script += "window.print();window.close();";<br />
Script += "</script>";<br />
<br />
ClientScript.RegisterStartupScript(this.GetType(), "print", Script);<br />
}<br />
|
|
|
|
|
can anybody explain about friend and protected friend briefly? i have seen somewhere it is protected or friend but not protected and friend...what is the use of protected friend? we have friend, protected separately?
pavan...
|
|
|
|
|
It's not called 'friend' in C# it's 'internal'.
'internal' means any class in the same assembly can access it.
'protected' means any class that any inheriting class can access it.
'internal protected' (or 'protected internal' ) means that any class in the same assembly AND any inheriting class can access it.
In .Net 2.0 you can have 'friend' assemblies. If you make an assembly a 'friend' of another then it will have access to anything marked internal as if it was in the same assembly.
MSDN: Access Modifiers[^]
MSDN: Friend Assemblies[^]
|
|
|
|
|
thanks, some what i have cleared..
pavan...
|
|
|
|
|
if u please explain it a little bit with an example.that explains the limit of using there modifiers
Thanks You.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
If theres any part of what I said that you don't understand go and buy a book on C#. Inheritance and assemblies are all very basic concepts and you need to understand the basics well if you want to use C# to it's full extent.
|
|
|
|
|
Protected internal ………meaning is protected or internal…which is selected by including
Both a protected and an internal modifier in the member declaration. The intuitive meaning of protected internal is “access limited to this program or types derived from the containing class.
Protected internal is a union of protected and internal in terms of
providing access but not restricting.
Meaning
Inherited types, even though they belong to a different assembly, have
access to the protected internal members
Types that reside in the same assembly, even if they are not derived from
the type; also have access to the protected internal members
pavan...
|
|
|
|
|
do u have any idea abt satellite assembly?
pavan...
|
|
|
|
|
Hello
Could you give me your top-10 list of C#/.Net pages to visit?
I'm relatively new to .Net, so I only know this one
|
|
|
|
|
|
lol I was thinking exactly the same thing :P
A few more:
Google[^] (especially handy for searching the msdn with "keywords site:msdn2.microsoft.com")
MSDN[^] The microsoft documentation and reference site. Not greta but occasionally handy.
Codeplex[^] The sourceforge of the .Net world.
Lutz Roeder's Reflector[^] The greatest .Net tool ever
|
|
|
|
|
Hello,
In .Net 2.0 version, windows form, we are using readonly datagrid. for this grid if user selects any cell and right click then windows context menu i.e. cut, copy, paste... is displaying.
Now user is selecting some other cells and try to paste then in rowheader it is dispalying edit icon. We don't want this edit icon should be display at rowheader but context menu should be display.
Your help is greatly appreciated.
Thanks & Regards,
Kumar
|
|
|
|
|
I create an application that writes data from a Richtextbox to a file on hard disk with my own extension. But Windows doesn't know that file, and when I double click it, an Open With.. window appear. Please help me to open my own files with my application when I double click it.
Thank you very much
Sorry for my bad English
|
|
|
|
|
This involves setting up information in the registry. Every app that opens it's docs via the explorer, has itself stored as the default in the registry.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you for replying my question, but i don't know much about this. Could you please tell me more about this ? Thank you very much
|
|
|
|
|
I'm not sure, to be honest. I have a rough idea, but I was intending mostly to show you enough to put you on the right track.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|