Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:21:29+00:00 2026-06-12T05:21:29+00:00

I have a custom control with a property called Offset that is type PointF.

  • 0

I have a custom control with a property called Offset that is type PointF.

I want to be able to edit the property from the Form Designer (it is currently disabled).

I read that I must add the EditorAttribute which points to a class derived from System.Drawing.Design.UITypeEditor.

It looks like there are quite a few built in types that derive from UITypeEditor already such as:

System.ComponentModel.Design.BinaryEditor
System.ComponentModel.Design.CollectionEditor
System.ComponentModel.Design.DateTimeEditor
System.ComponentModel.Design.MultilineStringEditor
System.ComponentModel.Design.ObjectSelectorEditor
System.Drawing.Design.ColorEditor
System.Drawing.Design.ContentAlignmentEditor
System.Drawing.Design.CursorEditor
System.Drawing.Design.FontEditor
System.Drawing.Design.FontNameEditor
System.Drawing.Design.IconEditor

… etc

I can’t find one for editing a PointF or Point type. It seems like this functionality should already exist since .NET exposes Point/PointF types all the time in the designer.

I’m hoping I don’t have to reinvent the wheel – I want to use the built in UITypeEditor type if it already exists.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:21:30+00:00Added an answer on June 12, 2026 at 5:21 am

    You can add a property to a custom control of type Point that allows editing in the control’s property grid using this code:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
     EditorBrowsable(EditorBrowsableState.Advanced),
     TypeConverter(typeof(PointConverter))]
    public Point MyPointProperty { get; set; }
    

    If you try the same sort of approach with a SizeF you’ll find there’s no built in .NET TypeConverter for a PointF. You can create your own though, I found one here (and copy and pasted most of the code below).

    With a PointF TypeConverter you can write a property of type PointF that’s editable in the property window:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
     EditorBrowsable(EditorBrowsableState.Advanced),
     TypeConverter(typeof(PointFConverter))]
    public PointF MyPointFProperty { get; set; }
    

    Here’s the PointF type converter code found in the article linked above:

    /// <summary>
    /// PointFConverter
    /// </summary>
    public class PointFConverter : ExpandableObjectConverter
    {
        /// <summary>
        /// Creates a new instance of PointFConverter
        /// </summary>
        public PointFConverter() {
        }
    
        /// <summary>
        /// Boolean, true if the source type is a string
        /// </summary>
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
            if (sourceType == typeof(string)) return true;
            return base.CanConvertFrom(context, sourceType);
        }
    
        /// <summary>
        /// Converts the specified string into a PointF
        /// </summary>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
            if (value is string) {
                try {
                    string s = (string)value;
                    string[] converterParts = s.Split(',');
                    float x = 0;
                    float y = 0;
                    if (converterParts.Length > 1) {
                        x = float.Parse(converterParts[0].Trim());
                        y = float.Parse(converterParts[1].Trim());
                    } else if (converterParts.Length == 1) {
                        x = float.Parse(converterParts[0].Trim());
                        y = 0;
                    } else {
                        x = 0F;
                        y = 0F;
                    }
                    return new PointF(x, y);
                } catch {
                    throw new ArgumentException("Cannot convert [" + value.ToString() + "] to pointF");
                }
            }
            return base.ConvertFrom(context, culture, value);
        }
    
        /// <summary>
        /// Converts the PointF into a string
        /// </summary>
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
            if (destinationType == typeof(string)) {
                if (value.GetType() == typeof(PointF)) {
                    PointF pt = (PointF)value;
                    return string.Format("{0}, {1}", pt.X, pt.Y);
                }
            }
            return base.ConvertTo(context, culture, value, destinationType);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a user control which exposes a custom type property called SoftwareItem.
I have a custom control that inherits from UserControl , and I can't get
I have a custom control in an aspx page that has a property named
I'm creating a custom control called FooControl derived from ItemsControl have a default style
I have a custom control type like: <Grid> ... </Grid> and Grid.BitmapEffect property. How
I have a custom control that own a property. Inside this custom control OnInit
I have custom control that extends DataGrid . It is called ExtendedDataGrid . I
Hopefully a simple question. I have a custom control with a dependency property that
I have developed a custom control with two public property called ListField and DataSource.
I have a custom control called TextBoxWithLabelAndUnits . From the name, you can tell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.