标题:请问如何在程序中在窗口中添加新的可以任意移动的TEXTBOX组件,
取消只看楼主
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
 问题点数:0 回复次数:2 
请问如何在程序中在窗口中添加新的可以任意移动的TEXTBOX组件,
请问如何在程序中在窗口中添加新的可以任意移动的TEXTBOX组件,
搜索更多相关主题的帖子: TEXTBOX 组件 窗口 
2005-03-02 09:50
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
得分:0 

我找到了例子,大家共乡一下, private void initProperty() { foreach(Control aa in this.Controls) { //aa.MouseEnter += new System.EventHandler(lmMouseEnter); aa.MouseUp += new System.Windows.Forms.MouseEventHandler(lmMouseUp); aa.MouseDown += new System.Windows.Forms.MouseEventHandler(lmMouseDown); } } private void lmMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { oldX=e.X; oldY=e.Y;

// this.textBox3.Text=sender.GetType().Name.ToString(); }

private void lmMouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { int nX,nY; nX=e.X; nY=e.Y; string oType=sender.GetType().Name.ToString(); switch (oType) { //case "PictureBox": //(sender as PictureBox).Left+=nX-oldX; //(sender as PictureBox).Top+=nY-oldY; //break;

//case "Button": //(sender as Button).Left+=nX-oldX; //(sender as Button).Top+=nY-oldY; //break; case "TextBox": (sender as TextBox).Left+=nX-oldX; (sender as TextBox).Top+=nY-oldY; break; //case "Label": //(sender as Label).Left+=nX-oldX; //(sender as Label).Top+=nY-oldY; //break; default: break; }

oldX=-1; oldY=-1; }

2005-03-02 19:07
jianfeixu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2005-1-24
得分:0 
上面是移动的,可是,还是不知道怎么添加TEXTBOX组件,可以写段程序给我么,
2005-03-02 19:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-12715-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.587474 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved