[program-l] Re: Homer .net with Visual Basic .net: how to programmatically populate text boxes and get their values

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Fri, 2 Oct 2009 13:31:15 -0400 (EDT)

Lbc (Layout by Code) automatically assigns a name to each control added to
the form.  The name has two parts seperated by an underscore character
(_):  the class of the control and the label of the control.  To ensure
unique names, make sure that two controls of the same type do not also
have the same label.  For example, the label of a labeled TextBox would be
a pair of controls with the names Label_Search and TextBox_Search.  Lbc
automatically appends a colon (:) to a label if one is not specified.  It
also automatically prepends an ampersand (&) if none is specified, thereby
making the initial letter the default access key of the control (so the
control can be focused or activated with Alt+Letter).  An Lbc form has a
property called Names, which is a dictionary that associates control names
and control objects.  Thus, you can get a reference to a TextBox with
C# syntax like

TextBox txt = dlg.Names["TextBox_Search"];

Thus, you can get a reference to a control on the form by passing its
name as a key to the dictionary called Names that is a property of the
parent, form object.  With that reference, you can read or write data to
the control.  You can also get such a reference as the return value of
the Lbc method that adds the control to the form.  The AddTextBox
method, or AddInputBox method (which includes a label before the
TextBox), returns a reference to the TextBox object that is added to the
form.

I appreciate the questions and feedback, as this helps me fine tune the
code and documentation before the 1.0 release.

Jamal

On Fri, 2 Oct 2009, Pranav
Lal wrote:

> Date: Fri, 2 Oct 2009 21:44:36 +0530
> From: Pranav Lal <pranav.lal@xxxxxxxxx>
> Reply-To: program-l@xxxxxxxxxxxxx
> To: program-l@xxxxxxxxxxxxx
> Subject: [program-l] Homer .net with Visual Basic .net: how to
>     programmatically populate text boxes and get their values
>
> Hi all,
>
> I am using the homer .net library. I have added 2 edit boxes. I am using
> Visual Basic .net.
>
> 1. How do I populate them programmatically? I can do that at the time of
> definition but what about at other points in the program?
>
> 2. How do I get the values entered into these boxes?
>
> Upon looking at the fruit basket code for visual basic, I can see that the
> text boxes have been mapped to variables. I cannot fully understand the
> mapping line.
> Dim txt As TextBox = CType(me.Names("TextBox_Fruit"), TextBox)
> What does the "TextBox_Fruit"), TextBox)" bit mean? There is no element
> anywhere else called "TextBox_Fruit".
>
> I realize that a variable caste is taking place but I am a shade lost in
> interpreting this conversion.
> Pranav
>
> ** To leave the list, click on the immediately-following link:-
> ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
> ** If this link doesn't work then send a message to:
> ** program-l-request@xxxxxxxxxxxxx
> ** and in the Subject line type
> ** unsubscribe
> ** For other list commands such as vacation mode, click on the
> ** immediately-following link:-
> ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
> ** or send a message, to
> ** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
>
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: