Position label and text in CreateComponentsCore()

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hey I hope someone can help me with a clean solution for the following
puzzle:

I have written a custom toolboxitem that overrides the
CreateComponentsCore() operation that returns two objects, a subclassed
label and a subclassed textbox. The purpose is to create a label and a
textbox that represent a database field (something similar to Microsoft
Access when dragging and dropping a field on a form).

Now my problem is how to position the two controls? In the
CreateComponentsCore() you cannot get the location on the designer since
they are not yet dropped on the designer yet. This means that both controls
will be created at the exact same location thus overlapping eachother. Is
there a clean way to position both controls in the CreateComponentsCore() so
that the textbox control will be positioned behind the label control?

I was thinking of adding a property named ShiftLeft to the subclassed
TextBox, set the value of ShiftLeft in the CreateComponentsCore() and in the
constructor of the subclassed Textbox make sure that TextBox.Left =
TextBox.Left + ShiftLeft but there has to be a better way (?)

Also I do NOT want to create a user control consisting of my custom label
and custom textbox because after creating the user should be able to move
label and textbox around as two seperate components.

Many thanks for any leads :)

Gabriel Lozano-Morán
Real Software


.



Relevant Pages

  • Dynamically creating labels and textboxes in a panel
    ... I have an array of polygons, and I need to create controls so that people ... string sLabelText, // text to use for the label ... TextBox txt, // the textbox control ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: asp.net textbox text not updating
    ... The following information is from the MSDN documentation and explains the ... dynamically created controls will pick up property values from the view ... > label, the second is a number and is added to the label as the text ... > property of a textbox, so the user can update it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Need Label visible in a VB6 TextBox
    ... You asked if a label could be put on top of a textbox; ... related to what you are trying to accomplish. ... contained by other controls or on top of other controls but not "inside" so ...
    (microsoft.public.vb.general.discussion)
  • Re: How do I speed up screen redraw on pocket PC application
    ... I think the main problem is likely due to the Label and textboxes ... > memory and load into textbox or label when necessary. ... > can just try reusing the existing controls so as to reduce UI processing. ... > Microsoft Online Support ...
    (microsoft.public.dotnet.framework.performance)
  • Referencing a Subprocedures Name
    ... The trick is to iterate through all the controls, ... Sub PastReply ... checkboxes to the collection that hosts the classes. ... >which is textbox specific I can simply reference the ...
    (microsoft.public.excel.programming)