Update property in pagepanel

Hi everybody,

I am doing a desktop App with a pagepanel with 2 pages. In each page there is a containercontrol:

  • Page 0: Login Access
  • Page 1: Main Page with different tools.

In page 0, when the user is logged, a property (‘ActiveUserName’) stores the username entered in the textfield ‘UserField’ and the page is changed to page 1. In this page, a welcome message is shown:
“Welcome [Username], what do you want to do?”

I have tried to add the ‘username’ from this property but when I run the App in debug mode the [user] is empty. Why?

I have tested the value stored in the property and it’s right. I change the panel and store the username with a Button with this code:

Window1.MainPanel.Value = 1 Window1.MainScreenShow.ActiveUserName = UserField.Text

In the ‘MainScreenShow’ Container control, I have included the welcome message with an ‘open’ event-handler with this code:

[code]Dim Text1 As String
Dim Text2 As String

Text1 = "Welcome "
Text2 = “, what do you want to do?”

me.Text = Text1 + Window1.MainScreenShow.ActiveUserName + Text2[/code]

What am I doing wrong? Could anyone help me, please?

Thank you very much.

Sergio

The open event has to happen before you can set the textfield, so it will be blank at that time. It would be better to call a method on MainScreenShow that sets both the field value and the welcome message.

Thanks Tim,

this is exactly my problem. How could I do the method? Could you help me and show me an example, please?

Thanks,
Sergio

Go to your containercontrol definition and add a method. (Click the container in the navigator and insert a method.) Call it SetUsername. Give it a parameter, name as string. So the method definition looks like

Sub SetUsername(name as string)

In the code of the method put

Dim Text1 As String
Dim Text2 As String
  
Text1 = "Welcome "
Text2 = ", what do you want to do?"

ActiveUserName = name
WelcomeMessage.Text = Text1 + name + Text2

Call it like

Window1.MainPanel.Value = 1
Window1.MainScreenShow.SetUsername(UserField.Text)

Thank you very much Tim,

it works perfectly. Only I have a last question, how could I change only the ‘name’ value to bold letter? This variable is not string type and I have not to use ‘name.bold’. What do you suggest?

For bold, you will need to either split the label into 3 labels so that you can bold just the name text or use a Styled TextArea.

Thanks Tim,

if you review the code that Tim Hare wrote, the label is split into 3 labels: text1, text2 and ‘name’. This last variable is the value that I want to change to bold.

Actually, he split it into 3 pieces, but you’re still probably displaying it in a single Label control. The Bold parameter affects the entire text in a Label’s .Text property. This is why I mentioned creating 3 labels - one for each piece of the text - so that you could apply the .Bold property to just the name portion.

Those are variables, not labels. Please be a little more precise in your description of what you want. Your last 2 posts are hard to understand.

Hi, sorry for my english. Surely I didn’t explain very well. Tim Jones is right, I want to have a label with the three variables (Text1 + name + text2) but I would like to highlight in bold the variable ‘name’. The only option may be dividing the label in 3 labels but I wonder if there was some other more elegant option.

Sorry again and thank you very much to both.

Sergio

Use a listbox 1 row 3 columns split the text in cell’s.

[code]ListBox1.ColumnCount=3

ListBox1.HasHeading=False
ListBox1.Heading(0)=“Name”
ListBox1.Heading(1)=“Age”
ListBox1.Heading(1)=“Phone”
ListBox1.Cell(ListBox1.LastIndex,0)=“myname”
ListBox1.Cell(ListBox1.LastIndex,1)=“20”
ListBox1.Cell(ListBox1.LastIndex,2)=“212-331-222”[/code]

Then use the

ListBox.CellTextChange ( Row as Integer, Column as Integer )

A listbox is not transparent.

This works nicely in a Canvas :

Sub Paint(g As Graphics, areas() As REALbasic.Rect) dim offset as integer g.drawstring("Normal text", 0, 20) offset = offset + g.StringWidth("Normal text ") g.Bold = True g.drawstring("Bold text", 0 + offset , 20) offset = offset + g.StringWidth("Bold text ") g.bold = False g.drawstring("Normal text", 0 + offset, 20) End Sub

Or - as I originally mentioned, you could use a TextArea with the “Styled” flag set. Review the User Guide here:

Using Styled Text

Hi everybody,

finally I have used a TextArea with StyledText as suggested Tim Jones. I think it’s the easiest option at least for my knowledge.

Thank you very much to everyone for your suggestions.

Sergio