Point like designer

  • Thread starter Thread starter Tamir Khason
  • Start date Start date
T

Tamir Khason

Question when I'm using property of Point (or Size) type in User Control. In
design time while adding the control you can edit X,Y each one.
I want to create my own struct like point to be able to appears as point in
designer. In my case I can see only ReadOnly "10x10" in Properties view
while adding this user control
Following the example:

[DefaultValue(typeof(Dimension),"16x16"), Category("Design"),

Description("Dimension Value"),

Editor (typeof(Dimension),typeof(System.Drawing.Design.UITypeEditor))]

public Dimension Size {get{return m_size;} set{m_size=value;}}

-----------------------

public struct Dimension

{

int m_inputs;

public int Inputs{get{return m_inputs;}set{m_inputs=value;}}

int m_outputs;

public int Outputs{get{return m_outputs;}set{m_outputs=value;}}

public Dimension(int inputs, int outputs)

{

m_inputs=inputs;

m_outputs = outputs;

}

public override string ToString()

{

return Inputs.ToString()+"x"+Outputs.ToString();

}



}


Please assist
 
Hi Tamir,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need that your own type can be
displayed as Size or Point in property window which can be expanded. If
there is any misunderstanding, please feel free to let me know.

As far as I know, we need to derive from TypeConverter class and implement
CanConvertFrom, ConvertFrom and ConvertTo in the this type. Here is an
article talking about this in detail. HTH.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/vsnetpropbrow.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Tamir,

You're welcome. Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top