|
Hi, and thanks for responding. Lets say I write mouse events for Form1; how do I wire them to 'every' control on the form?
this.MouseMove +=new MouseEventHandler(Form1_MouseMove);
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
//Do Something here
}
|
|
|
|
|
rich_wenger wrote: how do I wire them to 'every' control on the form?
this.MouseMove +=new MouseEventHandler(Form1_MouseMove);
btnOK.MouseMove += new MouseEventHandler(Form1_MouseMove);
txtName.MouseMove += new MouseEventHandler(Form1_MouseMove);
chkRemember.MouseMove += new MouseEventHandler(Form1_MouseMove); and so on. Or you could also do this:
foreach(Control ctl in this.Controls)
ctl.MouseMove += new MouseEventHandler(Form1_MouseMove); If you have controls inside other controls (panels or group boxes for example), you'll need to do that recursively. If you always use the same handler, the same routine will be called for events raised by any controls.
I hope this helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
And you can use the following sample code to add mousemove event handler to every control on your form (as Luis pointed out).
<br />
<br />
AttachEventHandler(this);<br />
<br />
void AttachEventHandler(Control ParentControl)<br />
{<br />
foreach (Control ctrl in ParentControl.Controls)<br />
{<br />
if (ctrl.HasChild == true)<br />
{<br />
AttachEventHandler(ctrl);
}<br />
else<br />
{<br />
ctrl.MouseMove += new MouseEventHandler(Form1_MouseMove);<br />
}<br />
}<br />
}
|
|
|
|
|
Thanks, I'll give it a try after lunch.
|
|
|
|
|
Your solution works except for the following statment:
Gulfraz Khan wrote: if (ctrl.HasChild == true)
It should actually read:
if (ctrl.HasChildren == true)
Thanks again.
|
|
|
|
|
Hi there,
i'm searching for a way to create a component from a control designer, and pass some parameters to it.
This create an instance of my object:
<br />
IDesignerHost h = (IDesignerHost)GetService(typeof(IDesignerHost));<br />
MyComponentType myComponent = (MyComponentType )h.CreateComponent(typeof(MyComponentType));<br />
What if i want to pass parameters to it?
Bye.
|
|
|
|
|
I will go deeper in my question.
I have already implemented a typeConverter for my component, which looks like that:
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(InstanceDescriptor))
{
System.Reflection.ConstructorInfo ci = typeof(FlatTabPage).GetConstructor(new Type[] { typeof(TypeOfTheParameterIwantToPass) });
return new InstanceDescriptor(ci, new object[] { i think the problem is here });
}
return base.ConvertTo(context, culture, value, destType);
}
Where i wrote I think the problem is here, i want to pass the control that actually is being designed. That is, i am designing a control A, and i want to create an instance of control B (from the A designer) passing A itself to it.
|
|
|
|
|
My application has a textbox,how can i make my textbox
enter numeric velues only
thanks
regards paula
|
|
|
|
|
|
|
A Simple way is to use the textbox's KeyPress Event. Check for the key pressed and if it is not a valid key then cancel the event (e.cancel) which will cause the key value not to be displayed.
The code below is an example of the KeyPress event for a textbox that only allows Numerics.
Hope this helps,
Craig
private void txtValue_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)<br />
{<br />
string s = "0123456789" + (char)8 + (char)9 ;<br />
if (s.IndexOf(e.KeyChar.ToString().ToUpper(),0) ==-1)<br />
{<br />
e.Handled = true;<br />
return;<br />
}<br />
}
|
|
|
|
|
i say you sorry for my bad english.
i've a problem with this code:
XmlTextReader reader = new XmlTextReader(@"c:\book.xml");<br />
XmlDocument doc = new XmlDocument();<br />
doc.Load(reader);<br />
<br />
XmlNodeList nodeList;<br />
XmlElement root = doc.DocumentElement;<br />
<br />
nodeList = root.SelectNodes("/bookstore/book/price[text()='11.99']");<br />
<br />
XmlElement newCd;<br />
XmlNode padre;<br />
<br />
foreach (XmlNode oldCd in nodeList) <br />
{<br />
newCd = doc.CreateElement("author");<br />
<br />
newCd.SetAttribute("visible", "true");<br />
<br />
newCd.InnerXml = oldCd.InnerXml;<br />
<br />
padre = oldCd.ParentNode;<br />
padre.ReplaceChild(newCd, oldCd);<br />
<br />
<br />
}<br />
doc.Save(@"c:\prova2.xml");
i have an XML with this structure:
<br />
bookstore<br />
book<br />
price 11.99 /price<br />
author .. author<br />
title .. /title<br />
..<br />
..<br />
/book<br />
/bookstore<br />
if in the code I write
nodeList = root.SelectNodes("/bookstore/book/price[text()>'11.00']");
the nodeList has 1 node because the expression is ok but i don't understand the reason that I write
nodeList = root.SelectNodes("/bookstore/book/price[text()='11.99']");
the nodeList.Count() results 0 and the program returns that there are no nodes matching the expression. the same thing happens if i try to test the content of title, author etc.
Can you help me?
|
|
|
|
|
Works fine for me. Maybe you are loading the wrong XML file? This is the code I used.
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList list = doc.DocumentElement.SelectNodes("/bookstore/book/price[text()='11.89']");
Console.WriteLine(list.Count);
and this is the XML file I used
<bookstore>
<book>
<price>11.99</price>
<author>X</author>
<title>Z</title>
</book>
</bookstore>
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil,
I say you thank you for your reply!!! )))
I still have a problem; if i have a document named book.xml in C:\ this code i wrote doesn't work
XmlTextReader reader = new XmlTextReader(@"c:\book.xml");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
XmlNodeList nodeList;
XmlElement root = doc.DocumentElement;
// nodeList = root.SelectNodes("/bookstore/book/price[text()>'9.00']"); <-- this query works
nodeList = root.SelectNodes("/bookstore/book/price[text()='11.99']"); // <-- this query doesn't work
Console.Write(nodeList.Count.ToString());
if i can't solve this problem my work doesn't go on
|
|
|
|
|
Well, the only thing I can think of is that your XML file might be different. Did you make sure it's exactly the same as you posted?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
oh my god i found the problem...
there was an error in the xml...and i spent more than 4 hours on this problem...
thank you Senthil
|
|
|
|
|
Could someone help me with showing three summary rows on the footer of the datagrid. I need to calculate sales total for and individual.
Then the total for all the sales assistance and lastly
the grand total for the whole department.
Any ideas
|
|
|
|
|
Hi,
I'm trying to create a log file in my application folder.
Have tried:
just "Applog.txt"
"..\Applog.txt"
"\Applog.txt"
"\\Applog.txt"
With no luck.
But if I do
"c:\\Applog.txt"
that works fine.
So what can I use to get the applog in my application folder.
Is there a function return the location from the assembly?
Regards
|
|
|
|
|
|
Have you tried @".\Applog.txt"
I always do as Senthil suggested:
string fileSpec = string.Format("{0}{1}Applog.txt", Application.StartupPath, Path.DirectorySeparatorChar);
|
|
|
|
|
Hi
Please Help in this situation
I have created an application to draw a image that contains Rectangles and others as a images. I just add them in the Picture box. I have completed up to creating the images but the problem comes when i want to rotate the images using the mouse. Not by using the angles given to text boxes. We have to predict the mouse movements and then we have to find the angle of the rotation for that angle we have to rotate the object. Is there any specific algorithm for that. I just have the contrl to the picture box.
With Luv,
Arun R.
-- modified at 7:44 Thursday 10th November, 2005
|
|
|
|
|
Hi
Please Help in this situation
I have created an application to draw a image that contains Rectangles and others as a images. I just add them in the Picture box. I have completed up to creating the images but the problem comes when i want to rotate the images using the mouse. Not by using the angles given to text boxes. We have to predict the mouse movements and then we have to find the angle of the rotation for that angle we have to rotate the object. Is there any specific algorithm for that. I just have the contrl to the picture box.
With Luv,
Arun R.
|
|
|
|
|
Hi!
I'm using Measurement Studio 7.1.
I have the problem to get a rectangle into a graph which shows
measurement data.
This rectangle should be as scrollable and zoomable as the
graph but my rectangle i insert is fix on the screen.
e.Graphics.DrawRectangle(new Pen(Color.Turquoise,2),10,10,50,50);// works!!! but without scrolling and zooming
Hope you can help me.
M.Friedel
|
|
|
|
|
I want to delete Temporary Internet Files, Cookie, and History by using C#.
However, the sample etc. were not found though I searched the Internet.
Please teach when you have the sample and information.
|
|
|
|
|
hello
i tried getting my old project that deals with processes into the new shiny c# 2005 and when i try running i get access denied from the 'System Idle Process' Process object when i try pulling the data out of TotalMilliseconds value (it worked just fine in vs2003) anyone got a clue on how to fix this?
thanks Gil
|
|
|
|