积极答复者
C#新建类无法使用(新建控件达不到预想效果)

问题
答案
-
- 已编辑 ThankfulHeartModerator 2012年10月8日 4:29
- 已建议为答案 Lisa ZhuModerator 2012年10月9日 2:01
- 已标记为答案 Lisa ZhuModerator 2012年10月12日 9:14
全部回复
-
你没有...new...所以没有效果罗
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
buttonnew bt = new buttonnew();
this.Controls.Add(bt);
}
}
public class buttonnew : Button
{
public buttonnew()
{
BackColor = Color.Red;
this.Text = "123";
this.Location = new Point(100, 64);
this.Size = new Size(100, 30);
}
}
}
-
相同问题...不要重问...OK?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ButtonNew bt = new ButtonNew();
this.Controls.Add(bt);
}
}
public class ButtonNew : Button
{
public ButtonNew()
{
BackColor = Color.Red;
this.Text = "new button";
this.Location = new Point(100, 64);
this.Size = new Size(100, 30);
}
}
}
-
我的是VS2005,要不你加一下我我把项目发给你你帮我看一下好吧?
- 已编辑 ThankfulHeartModerator 2012年10月8日 4:27 隐私泄露,删除
-
- 已编辑 ThankfulHeartModerator 2012年10月8日 4:29
- 已建议为答案 Lisa ZhuModerator 2012年10月9日 2:01
- 已标记为答案 Lisa ZhuModerator 2012年10月12日 9:14
-
你好,
你在这里:http://social.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/b858423f-f5a4-4952-a268-148b01ac4afe 发布了一个重帖。
并且很显然,我们的MVP(编程志愿者)对你所述的问题进行了很详尽的支持与解答。
所以,为了保证良好的论坛环境,我希望将这两个相同的帖子进行合并。另外,如果你的问题已经解决,请标记帮你解决问题的回复为答案。
谢谢你的支持与理解。
Lisa Zhu [MSFT]
MSDN Community Support | Feedback to us
- 已编辑 Lisa ZhuModerator 2012年10月8日 9:03