C#自定义控件运行时报错? 25
提示:“组件'E:\Work\Demo\xtButton\obj\Debug\xtButton.dll'未包含任何UserControl型别。”publicpartial...
提示:“组件 'E:\Work\Demo\xtButton\obj\Debug\xtButton.dll' 未包含任何 UserControl 型别。”
public partial class MyButton : Button
{
public MyButton()
{
InitializeComponent();
this.Width = 98;
this.Height = 30;
}
}
但是按F6编译的时候没有报错,提示编译成功。 展开
public partial class MyButton : Button
{
public MyButton()
{
InitializeComponent();
this.Width = 98;
this.Height = 30;
}
}
但是按F6编译的时候没有报错,提示编译成功。 展开
展开全部
代码是没有问题的 你在建这个类的时候是选的用户自定义控件这个类吗 下面给你看一个我自定义的可随便拖动的图片控件 希望能够帮助你
public partial class ExtPictureBox :PictureBox
{
public ExtPictureBox()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(ExtPictureBox_MouseDown);
this.MouseMove += new MouseEventHandler(ExtPictureBox_MouseMove);
}
Point original;
void ExtPictureBox_MouseMove(object sender, MouseEventArgs e)
{
//如果鼠标移动时还按了左键
if (e.Button == MouseButtons.Left)
{
PictureBox pictureBox = sender as PictureBox;
Point point = pictureBox.Parent.PointToClient(Control.MousePosition);
point.Offset(original);
pictureBox.Location = point;
}
}
void ExtPictureBox_MouseDown(object sender, MouseEventArgs e)
{
original = new Point(-e.X, -e.Y);
}
}
public partial class ExtPictureBox :PictureBox
{
public ExtPictureBox()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(ExtPictureBox_MouseDown);
this.MouseMove += new MouseEventHandler(ExtPictureBox_MouseMove);
}
Point original;
void ExtPictureBox_MouseMove(object sender, MouseEventArgs e)
{
//如果鼠标移动时还按了左键
if (e.Button == MouseButtons.Left)
{
PictureBox pictureBox = sender as PictureBox;
Point point = pictureBox.Parent.PointToClient(Control.MousePosition);
point.Offset(original);
pictureBox.Location = point;
}
}
void ExtPictureBox_MouseDown(object sender, MouseEventArgs e)
{
original = new Point(-e.X, -e.Y);
}
}
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询