Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello experts,

When we put any control inside cell of table layout panel
It includes properties like Col,Row,RowSpan,ColSpan to that control

many controls like this that include extra properties to other controls on form
e.g. Error provider, Tool tip, table layout panel etc.

I want to know how I can create this logic for my own control?
so that when I paste my custom component on form it include some extra properties to other controls on that form

thanks :)
Posted
Updated 18-Feb-13 18:37pm
v2
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 0:28am    
It's not clear what you are missing. Do you know how any property work, what are they for? If not, read about them.
Other than that, there is nothing general in this question. Each property has its own purpose; it makes no sense to describe them here.

Also, if you want someone to explain your logic of your own control, I cannot understand how such control can be your own. If you have a reason to create your own control, you should know your logic before you approach this work. :-)
—SA
Aarti Meswania 19-Feb-13 0:34am    
no reason for down-vote

I am aware with those properties read question again

when we put tablelayout on form it will include extra 4 property to other controls on form reside in table layout panel
same way...
I want to know how to include some extra property to the other controls on form when I put my own custom component to form

Aarti Meswania 19-Feb-13 0:38am    
I have update my question tell me if still it's not well defined.
thanks :)
Sergey Alexandrovich Kryukov 19-Feb-13 0:46am    
Not much. I cannot understand what do you hope to hear to help you. You say that you know how properties work. Then you should understand that you can add any properties and know how. And as this is your control, you should know the purpose; and no general advice is possible. You either don't understand some of those things, or I fail to understand what else should you know...
—SA
Aarti Meswania 19-Feb-13 0:49am    
yes I know to create property but problem is
I want to add property to other controls/components on form when I paste my own custom component on form

1 solution

Here is the final solution:

  1. Please read out discussion in the comments to the question. I think you have everything you need.
  2. Try it all, at last! You are wasting too much time on asking. You will find out how it all works when you try to create some custom control much clearly and even much faster.


[EDIT]

This is just a guess: maybe you cannot find a way to bind your control's property with a child control property. This can give you the idea:

C#
public partial class MyControl { // base class can be in other part

    TextBox MyTextBox = new TextBox();

    //...

    public string MyTextBoxText {
        get { return MyTextBox.Text; }
        set {
            if (value == MyTextBox.Text) return;
            MyTextBox.Text = value;
        }
    }

}


This way, you don't expose children (it would be against proper encapsulation), but expose just the properties you need. The designer will pick them, too.

A bit more problem is exposing those "internal" events. Can you find out how to do it? This is pure thinking, there are no secrets except understanding how properties and event instances work.

—SA
 
Share this answer
 
v3
Comments
Aarti Meswania 19-Feb-13 2:52am    
not an answer

just make my property 'xyz' public in my component class 'ANewComponent'
will not assign xyz property to the textbox1 I have on a form which have ANewComponent too
Sergey Alexandrovich Kryukov 19-Feb-13 11:42am    
Not a question!
You never explained what's the problem. You still did not. But I have a guess. What are you talking now is a very common problem, but all you need is just thinking...
—SA
Aarti Meswania 19-Feb-13 13:11pm    
:)
suppose I have create component UndoRedo it is my own component

In Form1,
Textbox1
UndoRedo1

now,
When I put Undoredo1 on form1 I want MemoryStack,Pointer 2 properties automatically generate for TextBox1

all logic/code to maintain MemoryStack,Pointer properties in UndoRedo Class

Hope now you exactly get what I want to do?
so,it is similar behavior like table layout panel
Sergey Alexandrovich Kryukov 19-Feb-13 13:31pm    
You never mentioned it before. Can you formulate your questions in a comprehensive and strict manner, separate concerns, express your self clearly and correctly? Well, what is "automatically generated" property?! Code generation? Reflection.Emit? Generation of assembly? What?

You should start with your ultimate goals, never hide anything from your question...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900