用户自定义控件为什么不能拖到Winform中了,急急急!

frankfuse 2008-12-15 07:57:12
怎么搞的,小弟虽然做Winform少,但印象中,真的是做好控件直接拉到Winform中就可以了啊。今天怎么搞的,怎么拖不了了呢。这么个小问题难着我了。请高手帮忙啊~
...全文
991 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
精诚软件 2011-03-27
  • 打赏
  • 举报
回复
这个问题,是vs工具的问题,只要重新打开就可以了
泡面之夏 2008-12-15
  • 打赏
  • 举报
回复
你自定义控件写的有点小问题吧,或者是编译有问题,你可以把你写的控件发给别人试试,看是否能够拖动控件.
slimfeng 2008-12-15
  • 打赏
  • 举报
回复
肯定是你编译环境的问题
slimfeng 2008-12-15
  • 打赏
  • 举报
回复
用你提供的代码生成控件,编译之后在工具箱中显示新创建的控件,并能拖到其他窗口中,没有任何问题。
wuyq11 2008-12-15
  • 打赏
  • 举报
回复
可以使用
参考
http://www.cnblogs.com/guanjinke/articles/583311.html
http://blog.csdn.net/zhanghefu/archive/2008/05/15/2448625.aspx
frankfuse 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 pcjbird 的回复:]
晕倒,刚刚用你的代码试了,可以拖动丫,你那个sPicBox是picturebox吧。。。
[/Quote]

天啊我做错什么了。。。,我这真的拖不了
hzy3625 2008-12-15
  • 打赏
  • 举报
回复
动态创建就不会有问题哦.呵呵
pcjbird 2008-12-15
  • 打赏
  • 举报
回复
对啊,你可以按5楼的方法试试,动态加载试试,有可能是你的编译环境有问题。。。
netboygg 2008-12-15
  • 打赏
  • 举报
回复
mark
pcjbird 2008-12-15
  • 打赏
  • 举报
回复
晕倒,刚刚用你的代码试了,可以拖动丫,你那个sPicBox是picturebox吧。。。
frankfuse 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hbxtlhx 的回复:]
可能你的编辑环境有问题了,可以试一下动态加载控件,这样有错会的话会很显示的显示出来。
[/Quote]
我试了,我把代码写进去,虽然没报错,但是自定义控件根本不显示啊。
北京的雾霾天 2008-12-15
  • 打赏
  • 举报
回复
可能你的编辑环境有问题了,可以试一下动态加载控件,这样有错会的话会很显示的显示出来。
frankfuse 2008-12-15
  • 打赏
  • 举报
回复
我新做出一个自定义控件也不行啊,拖不动~~~~
frankfuse 2008-12-15
  • 打赏
  • 举报
回复
设计界面:
namespace MakeUpTest
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.btnOpen = new System.Windows.Forms.Button();
this.btnDivid = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(191, 26);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(300, 300);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// btnOpen
//
this.btnOpen.Location = new System.Drawing.Point(12, 26);
this.btnOpen.Name = "btnOpen";
this.btnOpen.Size = new System.Drawing.Size(129, 23);
this.btnOpen.TabIndex = 1;
this.btnOpen.Text = "Open a New Pic";
this.btnOpen.UseVisualStyleBackColor = true;
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
//
// btnDivid
//
this.btnDivid.Location = new System.Drawing.Point(12, 69);
this.btnDivid.Name = "btnDivid";
this.btnDivid.Size = new System.Drawing.Size(75, 23);
this.btnDivid.TabIndex = 2;
this.btnDivid.Text = "Divid";
this.btnDivid.UseVisualStyleBackColor = true;
this.btnDivid.Click += new System.EventHandler(this.btnDivid_Click);
//
// btnStart
//
this.btnStart.Location = new System.Drawing.Point(12, 113);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(75, 23);
this.btnStart.TabIndex = 3;
this.btnStart.Text = "Start";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(552, 360);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.btnDivid);
this.Controls.Add(this.btnOpen);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button btnOpen;
private System.Windows.Forms.Button btnDivid;
private System.Windows.Forms.Button btnStart;
}
}

控件:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace MakeUpTest
{
public partial class SPic : UserControl
{
private int _seq = -1;
public SPic()
{
InitializeComponent();
}
public int sWidth
{
set
{
this.Width = value;
}
}
public int sHeight
{
set
{
this.Height = value;
}
}
public int sSeq
{
set
{
_seq = value;
}
get
{
return _seq;
}
}
public Image sImg
{
set
{
this.sPicBox.Image = value;
}
}

private void SPic_Load(object sender, EventArgs e)
{

}
}
}
貌似没什么特别的啊~~~~急~~~
pcjbird 2008-12-15
  • 打赏
  • 举报
回复
有这等问题?是不是【设计时】没弄好啊,把代码贴出来撒。。。
frankfuse 2008-12-15
  • 打赏
  • 举报
回复
太急了,忘了加分。明天一定补50分~~

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧