关于.net compact frame 中的 TypeConverter
看了网上有很多人写关于TypeConverter类的,但是,在CF中TypeConverter类只有一个空壳,没有虚函数,不知道该如何用?我试着把函数都填写进去了,但不能加override,因为TypeConverter没有函数,但是不起效果。求大侠帮忙。。代码如下:
public class MyConverter : TypeConverter
{
public bool CanConvertFrom(Type sourceType)
{
if (sourceType == typeof(string))
return true;
else
return false;
}
public bool CanConvertTo(Type destinationType)
{
if (destinationType == typeof(MyPoint3D))
return true;
else
return false;
}
public object ConvertTo(System.Globalization.CultureInfo culture, object value, Type destinationType)
{
return value.ToString();
}
public object ConvertFrom(System.Globalization.CultureInfo culture, object value)
{
TouchPlotAxis axis = new TouchPlotAxis();
axis.max = 10;
axis.min = -10;
return axis;
}
}
public struct MyPoint3D
{
public int x;
public int y;
public int z;
}
在DesignTimeAttribute.xmta文件中是这样描述的
<Class Name="MyComponent.MyPoint3D">
<TypeConverter>
typeof(MyConverter)
</TypeConverter>
</Class>
public class MyConverter : TypeConverter
{
public bool CanConvertFrom(Type sourceType)
{
if (sourceType == typeof(string))
return true;
else
return false;
}
public bool CanConvertTo(Type destinationType)
{
if (destinationType == typeof(MyPoint3D))
return true;
else
return false;
}
public object ConvertTo(System.Globalization.CultureInfo culture, object value, Type destinationType)
{
return value.ToString();
}
public object ConvertFrom(System.Globalization.CultureInfo culture, object value)
{
TouchPlotAxis axis = new TouchPlotAxis();
axis.max = 10;
axis.min = -10;
return axis;
}
}
public struct MyPoint3D
{
public int x;
public int y;
public int z;
}
在DesignTimeAttribute.xmta文件中是这样描述的
<Class Name="MyComponent.MyPoint3D">
<TypeConverter>
typeof(MyConverter)
</TypeConverter>
</Class>
...全文
相关推荐
大型集团公司数字化供应链变革及智慧采购整体解决方案.pptx
大型集团公司数字化供应链变革及智慧采购整体解决方案.pptx
政府搭建科技资源共享平台时,通常采用什么样的技术系统来匹配供需双方?.docx
政府搭建科技资源共享平台时,通常采用什么样的技术系统来匹配供需双方?
AI大模型医学影像诊断智能识别应用方案(二).pptx
AI大模型医学影像诊断智能识别应用方案(二).pptx
省级技术转移服务机构服务的技术合同成交额通常能达到什么量级?.docx
科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。
Delphi 13.2控件之Delphi Web Studio Pro User Guide.rar
Delphi 13.2控件之Delphi Web Studio Pro User Guide.rar


组件/控件开发
