Initial Positioning
-
I am writing my first 'real' C# control. It's a taskbar that can be positioned to Top/Bottom/Left/Right. What I need to know is which event do I need to use to position it to the bottom when it's initially created. I tried putting the code in the constructor but you cannot get the parent's properties until after creation. Can someone please point me in the right direction? Former VB programmer learning C#. X| Thank you
No comment, Mr. Senator
-
I am writing my first 'real' C# control. It's a taskbar that can be positioned to Top/Bottom/Left/Right. What I need to know is which event do I need to use to position it to the bottom when it's initially created. I tried putting the code in the constructor but you cannot get the parent's properties until after creation. Can someone please point me in the right direction? Former VB programmer learning C#. X| Thank you
No comment, Mr. Senator
You mean docked to a container, like a
Form
? See theDock
property, which can be set in the constructor. Also, you can support initialization after instantiation by implementing theISupportInitialize
interface. The VS.NET designer will automatically call theBeginInit
method after instantiating your control, and will callEndInit
when done in theInitializeComponent
call (you can do this yourself, too - I'm just telling you how VS.NET handles controls that implement this interface). This way, in your implementation of theEndInit
interface, you should have a validParent
reference (so long as your control was added to the parent'sControls
collection property) and can do what you need to. Implementing this interface is a great way to suport initialization of your control in steps. PS: You could do this using your own implementation without implementing the interface, but VS.NET won't care. Implementing theISupportInitialize
interface is a good way to add designer support for your control. There are other designer-oriented things you can do, which are handy for a lot of programmers. Read Enhancing Design-Time Support[^] in the .NET Framework SDK for more information.Microsoft MVP, Visual C# My Articles
-
I am writing my first 'real' C# control. It's a taskbar that can be positioned to Top/Bottom/Left/Right. What I need to know is which event do I need to use to position it to the bottom when it's initially created. I tried putting the code in the constructor but you cannot get the parent's properties until after creation. Can someone please point me in the right direction? Former VB programmer learning C#. X| Thank you
No comment, Mr. Senator
Take a look at this:C# does Shell, Part 3[^] That is really helpful. abcdabcdabcdabcda Don't forget, that's
Persian Gulf
not Arabian gulf!
Why do we close our eyes, when we dream?, When we cry?, When we imagine?, When we kiss?, Its because the most beautiful things in the world are unseen
Murphy:
Click Here![^]
I'm thirsty like sun, more landless than wind...
-
You mean docked to a container, like a
Form
? See theDock
property, which can be set in the constructor. Also, you can support initialization after instantiation by implementing theISupportInitialize
interface. The VS.NET designer will automatically call theBeginInit
method after instantiating your control, and will callEndInit
when done in theInitializeComponent
call (you can do this yourself, too - I'm just telling you how VS.NET handles controls that implement this interface). This way, in your implementation of theEndInit
interface, you should have a validParent
reference (so long as your control was added to the parent'sControls
collection property) and can do what you need to. Implementing this interface is a great way to suport initialization of your control in steps. PS: You could do this using your own implementation without implementing the interface, but VS.NET won't care. Implementing theISupportInitialize
interface is a good way to add designer support for your control. There are other designer-oriented things you can do, which are handy for a lot of programmers. Read Enhancing Design-Time Support[^] in the .NET Framework SDK for more information.Microsoft MVP, Visual C# My Articles
Thank you Heath this was extremely helpful.
No comment, Mr. Senator