日期:2014-05-17  浏览次数:20967 次

用什么办法把str转换成MouseEventArgs或者EventArgs类型?本人菜鸟,求高手解决
//输出的时候
MouseEventArgs mouseArgs为{X=189 Y=168}
//我定义了一个
string str="X=189 Y=168"
用什么办法把str转换成MouseEventArgs或者EventArgs类型?本人菜鸟,求高手解决。

------解决方案--------------------

            string str = "X=189 Y=168";
            Match match = System.Text.RegularExpressions.Regex.Match(str, "X=([0-9]+) Y=([0-9]+)");
            int x = int.Parse(match.Groups[1].Value);
            int y = int.Parse(match.Groups[2].Value);
            MouseEventArgs e = new MouseEventArgs(MouseButtons.Left, 1, x, y, 0);


------解决方案--------------------
引用:
Quote: 引用:

你给出的代码中哪一行需要将string转换为MouseEventArgs?

“VS设了断点以后显示出来的”跟你的题目又是有怎样关系的?看不明白你的描述。


说高级一点就是给你一个鼠标x,y位置如何转换成MouseEventArgs e


又变成“给你一个鼠标x,y位置”了?不是string了?

代码都有了,就看你能不能自己读懂了。