Write the RAD component that interacts with the. net property window (6)

Source: Internet
Author: User
It's the end of the weekend, so I made up all the parts that were not sent last time. When I sent the text part to the fifth article, it was actually completed, now what we want to send is to merge the source code of the type converter implemented by TypeConverter in self-order, without understanding the reason in self-order, if you have read the previous chapters and started the experiment, you will know the reason. I constructed my own data type converter according to the methods described in this article, the attribute window of IDE can also correctly expand and parse sub-attributes. However, when I modify sub-attributes, I find that there are two problems, first, the sub-attribute cannot be modified (I forgot the specific cause of this problem), and second, an error will be reported by modifying the string of the parent attribute (as if the attribute type is incorrect ), so I had to manually derive a new converter from TypeConverter (originally ExpandableObjectConverter) and reload most methods (introduced on MSDN ), the most important thing I think is the implementation of the ConvertFrom method. After this converter is constructed The performance window works very well. The two problems mentioned above have no problem. Now it is not the problem of selecting the base class, but the structure should be complete.
The following code is about PointF type conversion implemented by me. If it is a custom type, the construction method is the same. The most important part of the reload is the implementation of GetPropertys, the method of the base class cannot be directly returned. Otherwise, the value of the sub-attribute cannot be modified and the GetPropertys of TypeDescriptor must be returned. For the reason, please refer to the related articles on MSDN.
# Region PointF conversion class implementation
/// <Summary>
/// Implementation of the PointF conversion class
/// </Summary>
Internal sealed class PointFConverter: TypeConverter
{
/// <Summary>
/// The CanConvertFrom method for reload TypeConverter
/// </Summary>
/// <Param name = "context"> </param>
/// <Param name = "sourceType"> </param>
/// Target type to be tested
/// <Returns> </returns>
Public override bool CanConvertFrom (ITypeDescriptorContext context,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.