Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WinForm
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 Smile | :)
Posted 18-Feb-13 19:25pm
Edited 18-Feb-13 19:37pm
v2
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 19-Feb-13 0:38am
   
I have update my question tell me if still it's not well defined.
thanks :)
Sergey Alexandrovich Kryukov at 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 at 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
Sergey Alexandrovich Kryukov at 19-Feb-13 0:56am
   
Paste? How is this related to the problem? or what's the problem? Do you mean the work via the designer? It will access all your public properties. However, if the properties types are complex types of your own, you will need to support the editors for them and other things related to PropertyGrid customization. Will you need it? This would be quite a difficult topic, due to some problems...
—SA
Aarti Meswania at 19-Feb-13 0:59am
   
yes thanks you understood
now what should I do to perform this?
please will u guide me?
 
:)
Sergey Alexandrovich Kryukov at 19-Feb-13 1:11am
   
Excuse me, perform what?
—SA
Aarti Meswania at 19-Feb-13 1:13am
   
I mean to to say I want work via the designer how to do this?
Sergey Alexandrovich Kryukov at 19-Feb-13 1:27am
   
I already told you: just implement your properties, make them public. The designer will see them.
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here is the final solution:
 
  1. Please read out discussion in the comments to the question. I think you have everything you need.
  2.  
  3. 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:
 
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
  Permalink  
v3
Comments
Aarti Meswania at 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 at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100