解决方案 »
- Winform界面设计问题
- 请教个问题
- 怎么写开奖器
- Windows系统上,如何实现在远程PC上弹出一个提示框?
- Control的Invoke和BeginInvoke
- 关于配置文件的问题
- 有谁用过FarPoint.Spread.for.Windows.Forms,怎么实现调整行列宽度时里面的数据自动折行调整?
- 不要调试马上作答:这会抛出什么异常
- OracleParameter 顺序该如何才能争取那。DEBUG时候顺序是争取的。但还是无法更新数据。
- 关于RangeValidator 控件问题!
- 无法嵌入互操作类型“HTMLInputElementClass”。请改用适用的接口
- 小弟有个C#的问题,希望各位帮忙解决下
using System.ComponentModel;
using System.Globalization;
using System.Drawing;public class PointConverter : TypeConverter {
// Overrides the CanConvertFrom method of TypeConverter.
// The ITypeDescriptorContext interface provides the context for the
// conversion. Typically, this interface is used at design time to
// provide information about the design-time container.
public override bool CanConvertFrom(ITypeDescriptorContext context,
Type sourceType) {
if (sourceType == typeof(string)) {
return true;
}
return base.CanConvertFrom(context, sourceType);
}
// Overrides the ConvertFrom method of TypeConverter.
public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value) {
if (value is string) {
string[] v = ((string)value).Split(new char[] {','});
return new Point(int.Parse(v[0]), int.Parse(v[1]));
}
return base.ConvertFrom(context, culture, value);
}
// Overrides the ConvertTo method of TypeConverter.
public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType) {
if (destinationType == typeof(string)) {
return ((Point)value).X + "," + ((Point)value).Y;
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
// ContactCollectionEditor.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;namespace Samples.AspNet.CS.Controls
{
public class ContactCollectionEditor : CollectionEditor
{
public ContactCollectionEditor(Type type)
: base(type)
{
} protected override bool CanSelectMultipleInstances()
{
return false;
} protected override Type CreateCollectionItemType()
{
return typeof(Contact);
}
}
}