我自己的一个类:
public class ImageStyle{
public Unit Width{get;set;}
public Unit Height{...}
public string CssClass{...}
public int BorderWidth{...}
public Color BorderColor{...}
}
我想加一个类似于Font的控件属性的类(ImageStyle)
在设计模式的属性窗口中
左边有一个加号图片可以展开,看到这个类的成员,
这样,就可以直接设置他的Width,Height等属性哎,Google上找了几天都没望 :(
public class ImageStyle{
public Unit Width{get;set;}
public Unit Height{...}
public string CssClass{...}
public int BorderWidth{...}
public Color BorderColor{...}
}
我想加一个类似于Font的控件属性的类(ImageStyle)
在设计模式的属性窗口中
左边有一个加号图片可以展开,看到这个类的成员,
这样,就可以直接设置他的Width,Height等属性哎,Google上找了几天都没望 :(
解决方案 »
- 关于picturebox显示图像问题
- 全局Hook怎么模拟ctrl?
- vs2008,考验各路高手的时候来了。。。
- 存储过程的参数定义时,@和@@有什么区别吗?
- 新手50分求助,急!!!
- 怎样在vs2003.net 中显示子窗口?初学者,谢谢!
- 取位查询??搞了很多天觉得有点难请教!
- 如何实现dataGrid列名的更改?
- 急! 请大侠们帮忙--字体(Font)的单位换算
- 請問能用一條insert語句﹐插入多條記錄嗎
- 如何在选择了RadioButtonList某一项时弹出一个confirm窗口,如果选择取消则不提交数据且RadioButton的所有项都保持非选择状态
- 在C#中如何使用APIVirtualQueryEx,
在把那个EditType反编译看下。
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;public A : Component
{
public A()
{
_iS = new ImageStyle(); // 先实例化一个ImageStyle。
}
public ImageStyle IS
{
set{ _iS = value; }
get{ return _iS; }
} private ImageStyle _iS;
}楼主把这段代码拷进去看看。
vs2005能看,Font是FontInfo类,大致是这样的
namespace System.Web.UI.WebControls
{
// 摘要:
// Encapsulates the font properties of text. This class cannot be inherited.
public sealed class FontInfo
{
// 摘要:
// Gets or sets a value that indicates whether the font is bold.
//
// 返回值:
// true if the font is bold; otherwise, false. The default value is false.
[DefaultValueAttribute(false)]
[NotifyParentPropertyAttribute(true)]
public bool Bold { get; set; }
//
// 摘要:
// Gets or sets a value that indicates whether the font is italic.
//
// 返回值:
// true if the font is italic; otherwise, false. The default value is false.
[DefaultValueAttribute(false)]
[NotifyParentPropertyAttribute(true)]
public bool Italic { get; set; }
public class Test
{
private MyCxpandableClass cc = new MyCxpandableClass();
public MyCxpandableClass CC
{
get
{
return cc;
}
set
{
cc = value;
}
}
}
// 作为上下个类的属性的类,为了可展开编辑,扩展转换类(在后面)
[TypeConverterAttribute(typeof(MyExpandableObjectConverter))]
public class MyCxpandableClass
{
private int a;
private float b;
public int A
{
get
{
return a;
}
set
{
a = value;
}
}
public float B
{
get
{
return b;
}
set
{
b = value;
}
}
}
// 类型转换类
public class MyExpandableObjectConverter: System.ComponentModel.ExpandableObjectConverter
{
public MyExpandableObjectConverter()
{
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(System.String))
return true; return base.CanConvertFrom (context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(MyCxpandableClass))
return true; return base.CanConvertTo (context, destinationType);
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if(destinationType == typeof(System.String) && value is MyCxpandableClass)
{
MyCxpandableClass so = (MyCxpandableClass)value; return "属性设置";
}
return base.ConvertTo (context, culture, value, destinationType);
}
}
{
if(destinationType == typeof(System.String) && value is MyCxpandableClass)
{
MyCxpandableClass so = (MyCxpandableClass)value; return "属性设置";
}
return base.ConvertTo (context, culture, value, destinationType);
}################
MyCxpandableClass so = (MyCxpandableClass)value;return "属性设置";
################
上面这两句是为了做什么啊?
查找自定义控件开发。
public class ImageStyle
{
public ImageStyle()
{
} private string name;
private int age; public string Name
{
get {return name;}
set {name = value;}
} public int Age
{
get {return age;}
set {age = value;}
}
}
http://community.csdn.net/Expert/topic/4339/4339217.xml?temp=.8715631