Glide TextBlock not updating

Hi,

I can not figure out how to update a TextBlock.

I have created a simple button, and when I push the button “Button Tapped” shows in my output window, but my label does not update. lblMain is valid at the point of execution.

Any thoughts?

void btn_TapEvent(object sender)
        {
            Debug.Print("Button Tapped");

            TextBlock lblMain = (TextBlock)mainWindow.GetChildByName("lblMain");
            lblMain.Text = "TheTextChange";
            mainWindow.FillRect(lblMain.Rect);
            lblMain.Invalidate();
           
        }

I can’t see anything wrong with that snippet but here’s a full example.


using System.Threading;
using Microsoft.SPOT;

using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;

//<Glide Version="1.0.7">
//  <Window Name="window" Width="480" Height="272" BackColor="dce3e7">
//    <TextBlock Name="textBlock" X="110" Y="104" Width="100" Height="32" Alpha="255" Text="I'm a label." TextAlign="Center" Font="4" FontColor="000000"/>
//    <Button Name="button" X="0" Y="104" Width="80" Height="32" Alpha="255" Text="Button" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
//  </Window>
//</Glide>

namespace GlideSlideGad
{
    public partial class Program
    {
        // This will hold the main window.
         Window window;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            // Load the window
            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));

            // Activate touch
            GlideTouch.Initialize();

            // Initialize the window.
            InitWin();

            // Assigning a window to MainWindow flushes it to the screen.
            // This also starts event handling on the window.
            Glide.MainWindow = window;
        }

         void InitWin()
        {
            // Get the TextBlock
            TextBlock textBlock = (TextBlock)window.GetChildByName("textBlock");
            Button button = (Button)window.GetChildByName("button");

            button.TapEvent += button_TapEvent;
        }

         void button_TapEvent(object sender)
        {
            TextBlock textBlock = (TextBlock)window.GetChildByName("textBlock");
            string originalText = textBlock.Text;

            // Change the text
            textBlock.Text = "I was tapped.";

            window.FillRect(textBlock.Rect);
            textBlock.Invalidate();

            // Wait for 3 seconds and revert.
            Thread.Sleep(3000);
            textBlock.Text = originalText;
            window.FillRect(textBlock.Rect);
            textBlock.Invalidate();
        }
    }
}


I’ve never used the FillRect call you are using. I just set the text with TextBox.Text as you are doing and then call the Invalidate() function and this causes it to be redrawn.

The only time I do a rect function is when updating a TextBlock as this does not erase the background first. I then call this before I update the TextBlock


                CurrentWindow.Graphics.DrawRectangle(timeDateText.Rect, CurrentWindow.BackColor, 255);

1 Like

@ Dave McLaughlinKing

The suggestion you provided with clearing the Rectangle first works! (+1 for you!)

I now have the following code. Works like a charm

Thank you both for replying!

void btn_TapEvent(object sender)
        {
            Debug.Print("Button Tapped");

            TextBlock lblMain = (TextBlock)mainWindow.GetChildByName("lblMain");

            mainWindow.Graphics.DrawRectangle(lblMain.Rect, mainWindow.BackColor, 255);

            lblMain.Text = "TheTextChange";
            //mainWindow.FillRect(lblMain.Rect);
            lblMain.Invalidate();
           
        }

@ Dave McLaughlin - I’m doing a project on FEZ Spider that takes user ID and Password from a user.
Im new to GHI gadgeteer and also c#.

I’m Using Glide for the display “DisplayTE35”

I don’t know How to show the tapped buttons’ numbers into the passwordBox…
Here is my code


using System;
using System.IO;
using Microsoft.SPOT.IO;
using GHI.IO;
using GHI.IO.Storage;
using System.Collections;
using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;
using Microsoft.SPOT;
using System.Threading;

using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Hardware;

using Gadgeteer.Networking;


/*
<Glide Version="1.0.7">
  <Window Name="window" Width="320" Height="240" BackColor="dce3e7">
    <TextBlock Name="Text1" X="0" Y="0" Width="320" Height="240" Alpha="255" Text="Welcome to YAN Access Control System" TextAlign="center" TextVerticalAlign="Top" Font="5" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <Button Name="btn1" X="20" Y="50" Width="40" Height="32" Alpha="255" Text="1" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn2" X="75" Y="50" Width="40" Height="32" Alpha="255" Text="2" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn3" X="130" Y="50" Width="40" Height="32" Alpha="255" Text="3" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn4" X="20" Y="95" Width="40" Height="32" Alpha="255" Text="4" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn5" X="75" Y="95" Width="40" Height="32" Alpha="255" Text="5" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn6" X="130" Y="95" Width="40" Height="32" Alpha="255" Text="6" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn7" X="20" Y="140" Width="40" Height="32" Alpha="255" Text="7" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn8" X="75" Y="140" Width="40" Height="32" Alpha="255" Text="8" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn9" X="130" Y="140" Width="40" Height="32" Alpha="255" Text="9" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <PasswordBox Name="passwordBox" X="200" Y="120" Width="80" Height="32" Alpha="255" Text="" TextAlign="Center" Font="2" FontColor="000000"/>
    <TextBlock Name="Text2" X="180" Y="70" Width="130" Height="32" Alpha="255" Text="ID and Password" TextAlign="Center" TextVerticalAlign="Top" Font="4" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <TextBlock Name="Text3" X="180" Y="50" Width="130" Height="32" Alpha="255" Text="Enter User" TextAlign="center" TextVerticalAlign="Top" Font="5" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <Button Name="btnEsc" X="20" Y="185" Width="40" Height="32" Alpha="255" Text="ESC" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btnEnter" X="130" Y="185" Width="40" Height="32" Alpha="255" Text="Enter" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn0" X="75" Y="185" Width="40" Height="32" Alpha="255" Text="0" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Image Name="image1" X="200" Y="158" Width="80" Height="60" Alpha="255"/>
    <TextBox Name="userId" X="199" Y="88" Width="80" Height="32" Alpha="255" Text="" TextAlign="Left" Font="4" FontColor="000000"/>
  </Window>
</Glide> 
*/


namespace Glide_1
{

    public class Program
    {
        public static PasswordBox password;

        public static void Main()
        {
            startProgram();           
        }
        public static void startProgram()
        {
            Debug.Print("Program Started!");

            GHI.Glide.Display.Window window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));

            GlideTouch.Initialize();

            GHI.Glide.UI.Button btn1 = (GHI.Glide.UI.Button)window.GetChildByName("btn1");
            btn1.TapEvent += OnTap1;
            GHI.Glide.UI.Button btn2 = (GHI.Glide.UI.Button)window.GetChildByName("btn2");
            btn2.TapEvent += OnTap2;
            GHI.Glide.UI.Button btn3 = (GHI.Glide.UI.Button)window.GetChildByName("btn3");
            btn3.TapEvent += OnTap3;
            GHI.Glide.UI.Button btn4 = (GHI.Glide.UI.Button)window.GetChildByName("btn4");
            btn4.TapEvent += OnTap4;
            GHI.Glide.UI.Button btn5 = (GHI.Glide.UI.Button)window.GetChildByName("btn5");
            btn5.TapEvent += OnTap5;
            GHI.Glide.UI.Button btn6 = (GHI.Glide.UI.Button)window.GetChildByName("btn6");
            btn6.TapEvent += OnTap6;
            GHI.Glide.UI.Button btn7 = (GHI.Glide.UI.Button)window.GetChildByName("btn7");
            btn7.TapEvent += OnTap7;
            GHI.Glide.UI.Button btn8 = (GHI.Glide.UI.Button)window.GetChildByName("btn8");
            btn8.TapEvent += OnTap8;
            GHI.Glide.UI.Button btn9 = (GHI.Glide.UI.Button)window.GetChildByName("btn9");
            btn9.TapEvent += OnTap9;
            GHI.Glide.UI.Button btn0 = (GHI.Glide.UI.Button)window.GetChildByName("btn0");
            btn0.TapEvent += OnTap0;
            GHI.Glide.UI.Button btnEsc = (GHI.Glide.UI.Button)window.GetChildByName("btnEsc");
            btnEsc.TapEvent += OnTapEsc;
            GHI.Glide.UI.Button btnEnter = (GHI.Glide.UI.Button)window.GetChildByName("btnEnter");
            btnEnter.TapEvent += OnTapEnter;

            GHI.Glide.UI.PasswordBox pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
           
            Glide.MainWindow = window;

            Thread.Sleep(-1);
        }

        private static void OnTap1(object sender)
        {
            Debug.Print("1 tapped.");
            GHI.Glide.Display.Window window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));
            PasswordBox passw = (PasswordBox)window.GetChildByName("passwordBox");
            window.Graphics.DrawRectangle(passw.Rect, window.BackColor, 255);
            passw.Text = "TheTextChange";
            window.FillRect(passw.Rect);
            passw.Invalidate();
        }
        private static void OnTap2(object sender)
        {
            Debug.Print("2 tapped.");
        }
        private static void OnTap3(object sender)
        {
            Debug.Print("3 tapped.");
        }
        private static void OnTap4(object sender)
        {
            Debug.Print("4 tapped.");
        }
        private static void OnTap5(object sender)
        {
            Debug.Print("5 tapped.");
        }
        private static void OnTap6(object sender)
        {
            Debug.Print("6 tapped.");
        }
        private static void OnTap7(object sender)
        {
            Debug.Print("7 tapped.");
        }
        private static void OnTap8(object sender)
        {
            Debug.Print("8 tapped.");
        }
        private static void OnTap9(object sender)
        {
            Debug.Print("9 tapped.");
        }
        private static void OnTap0(object sender)
        {
            Debug.Print("0 tapped.");
        }
        private static void OnTapEsc(object sender)
        {
            Debug.Print("Ecs tapped.");
        }
        private static void OnTapEnter(object sender)
        {
            Debug.Print("Enter tapped.");
        }

    }
}


First of all, as per the original post, don’t use the FillRect call.

In your OnTap handler, you can either play around with the Text or as I do, create a String that will hold the password. Just concatenate this and display it in the OnTap. A change to your code below will work. Remember that the PasswordBox shows * and not the value.


private static void OnTap1(object sender)
{
       Debug.Print("1 tapped.");
       GHI.Glide.Display.Window window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));
       PasswordBox passw = (PasswordBox)window.GetChildByName("passwordBox");
       passw.Text += "1";
       passw.Invalidate();
}

You don’t need the following call with EditBox’s only with TextBlock, I prefer to set their background to the same as the window and set the ShowBackColor property. This saves you having to wipe the background first.

Here’s a handy tip too for the OnTap, only use the ONE function for this and use the Tag property to indicate which button.


GHI.Glide.UI.Button btn1 = (GHI.Glide.UI.Button)window.GetChildByName("btn1");
btn1.Tag = "1";
btn1.TapEvent += OnTap1;

GHI.Glide.UI.Button btn2 = (GHI.Glide.UI.Button)window.GetChildByName("btn2");
btn1.Tag = "2";
btn1.TapEvent += OnTap1;   // Use the same function. You can read the tag back in the code.

@ Dave McLaughlin -
Thanks very much this helps a lot.
Here is what I did finally and works perfectly.


using System;
using Microsoft.SPOT;
using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;
using GHI.IO;
using GHI.IO.Storage;
using System.Threading;

/*
<Glide Version="1.0.7">
  <Window Name="window" Width="320" Height="240" BackColor="dce3e7">
    <TextBlock Name="Text1" X="0" Y="0" Width="320" Height="240" Alpha="255" Text="Welcome to YAN Access Control System" TextAlign="center" TextVerticalAlign="Top" Font="5" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <Button Name="btn1" X="20" Y="50" Width="40" Height="32" Alpha="255" Text="1" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn2" X="75" Y="50" Width="40" Height="32" Alpha="255" Text="2" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn3" X="130" Y="50" Width="40" Height="32" Alpha="255" Text="3" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn4" X="20" Y="95" Width="40" Height="32" Alpha="255" Text="4" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn5" X="75" Y="95" Width="40" Height="32" Alpha="255" Text="5" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn6" X="130" Y="95" Width="40" Height="32" Alpha="255" Text="6" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn7" X="20" Y="140" Width="40" Height="32" Alpha="255" Text="7" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn8" X="75" Y="140" Width="40" Height="32" Alpha="255" Text="8" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn9" X="130" Y="140" Width="40" Height="32" Alpha="255" Text="9" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <PasswordBox Name="passwordBox" X="200" Y="120" Width="100" Height="32" Alpha="255" Text="" TextAlign="Center" Font="2" FontColor="000000"/>
    <TextBlock Name="Text2" X="200" Y="100" Width="100" Height="32" Alpha="255" Text="Password" TextAlign="Left" TextVerticalAlign="Top" Font="5" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <TextBlock Name="Text3" X="200" Y="40" Width="100" Height="32" Alpha="255" Text="User ID" TextAlign="Left" TextVerticalAlign="Top" Font="5" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <Button Name="btnEsc" X="18" Y="185" Width="44" Height="32" Alpha="255" Text="Back" Font="5" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btnEnter" X="128" Y="185" Width="44" Height="32" Alpha="255" Text="Enter" Font="5" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <Button Name="btn0" X="75" Y="185" Width="40" Height="32" Alpha="255" Text="0" Font="6" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
    <TextBox Name="userId" X="200" Y="60" Width="100" Height="32" Alpha="255" Text="" TextAlign="Center" Font="4" FontColor="000000"/>
  </Window>
</Glide> 
*/
namespace AC
{
    class GlideM
    {
        //public static PasswordBox passw;
        private GHI.Glide.Display.Window window; 
        private bool txtSelect = true;
        private Mode current;
        //public GHI.Glide.UI.PasswordBox pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
        private enum Mode { Initial, Streaming, Sending, Receiving, Testing,cvb,cvbcvb };
        private string txtu;
        private string txtp;
        GHI.Glide.UI.PasswordBox pass;
        GHI.Glide.UI.TextBox usr;
        WebService wb;
            
        public GlideM()
        { 
            window= GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.window));
            current = Mode.Initial;
            wb = new WebService();
        }

        public void startProgram()
        {
            Debug.Print("Program Started!");

            //GHI.Glide.Display.Window window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));

            GlideTouch.Initialize();

            GHI.Glide.UI.Button btn1 = (GHI.Glide.UI.Button)window.GetChildByName("btn1");
            btn1.TapEvent += OnTap1;
            GHI.Glide.UI.Button btn2 = (GHI.Glide.UI.Button)window.GetChildByName("btn2");
            btn2.TapEvent += OnTap2;
            GHI.Glide.UI.Button btn3 = (GHI.Glide.UI.Button)window.GetChildByName("btn3");
            btn3.TapEvent += OnTap3;
            GHI.Glide.UI.Button btn4 = (GHI.Glide.UI.Button)window.GetChildByName("btn4");
            btn4.TapEvent += OnTap4;
            GHI.Glide.UI.Button btn5 = (GHI.Glide.UI.Button)window.GetChildByName("btn5");
            btn5.TapEvent += OnTap5;
            GHI.Glide.UI.Button btn6 = (GHI.Glide.UI.Button)window.GetChildByName("btn6");
            btn6.TapEvent += OnTap6;
            GHI.Glide.UI.Button btn7 = (GHI.Glide.UI.Button)window.GetChildByName("btn7");
            btn7.TapEvent += OnTap7;
            GHI.Glide.UI.Button btn8 = (GHI.Glide.UI.Button)window.GetChildByName("btn8");
            btn8.TapEvent += OnTap8;
            GHI.Glide.UI.Button btn9 = (GHI.Glide.UI.Button)window.GetChildByName("btn9");
            btn9.TapEvent += OnTap9;
            GHI.Glide.UI.Button btn0 = (GHI.Glide.UI.Button)window.GetChildByName("btn0");
            btn0.TapEvent += OnTap0;
            GHI.Glide.UI.Button btnEsc = (GHI.Glide.UI.Button)window.GetChildByName("btnEsc");
            btnEsc.TapEvent += OnTapEsc;
            GHI.Glide.UI.Button btnEnter = (GHI.Glide.UI.Button)window.GetChildByName("btnEnter");
            btnEnter.TapEvent += OnTapEnter;

            GHI.Glide.UI.TextBox txtusrID = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            txtusrID.TapEvent += txtusrID_TapEvent;
            txtusrID.Tag = true;
            GHI.Glide.UI.PasswordBox txtPass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            txtPass.TapEvent += txtPass_TapEvent;
            txtPass.Tag = false;
            //GHI.Glide.UI.PasswordBox pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");

            Glide.MainWindow = window;

            Thread.Sleep(-1);
        }

        void txtPass_TapEvent(object sender)
        {
            Debug.Print("pass tapped.");
            txtSelect = false;
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            pass.Tag = true;
            
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            usr.Tag = false;
            pass.Invalidate();
            usr.Invalidate();
        }

        void txtusrID_TapEvent(object sender)
        {
            Debug.Print("txtusr tapped.");
            txtSelect = true;
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            pass.Tag = false;
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            usr.Tag = true;
            pass.Invalidate();
            usr.Invalidate();
        }
        private void OnTap1(object sender)
        {
            Debug.Print("1 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "1";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "1";
                pass.Invalidate();
            }

        }
        private void OnTap2(object sender)
        {
            Debug.Print("2 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "2";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "2";
                pass.Invalidate();
            }

        }
        private void OnTap3(object sender)
        {
            Debug.Print("3 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "3";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "3";
                pass.Invalidate();
            }
        }
        private void OnTap4(object sender)
        {
            Debug.Print("4 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "4";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "4";
                pass.Invalidate();
            }
        }
        private void OnTap5(object sender)
        {
            Debug.Print("5 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "5";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "5";
                pass.Invalidate();
            }
        }
        private void OnTap6(object sender)
        {
            Debug.Print("6 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "6";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "6";
                pass.Invalidate();
            }
        }
        private void OnTap7(object sender)
        {
            Debug.Print("7 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "7";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "7";
                pass.Invalidate();
            }
        }
        private void OnTap8(object sender)
        {
            Debug.Print("8 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "8";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "8";
                pass.Invalidate();
            }
        }
        private void OnTap9(object sender)
        {
            Debug.Print("9 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "9";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "9";
                pass.Invalidate();
            }
        }
        private void OnTap0(object sender)
        {
            Debug.Print("0 tapped.");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            if ((bool)usr.Tag)
            {
                string txtu = usr.Text;
                usr.Text = txtu + "0";
                usr.Invalidate();
            }
            else
            {
                string txtp = pass.Text;
                pass.Text = txtp + "0";
                pass.Invalidate();
            }
        }
        private void OnTapEsc(object sender)
        {
            Debug.Print("Ecs tapped.");

            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            string txtp = pass.Text;
            string txtu = usr.Text;

            if (txtSelect)
            {
                if (txtu.Length > 0)
                {
                    usr.Text = txtu.Substring(0, txtu.Length - 1);
                    usr.Invalidate();
                }
            }
            else
            {
                if (txtp.Length > 0)
                {
                    pass.Text = txtp.Substring(0, txtp.Length - 1);
                    pass.Invalidate();
                }
            }

        }
        private void OnTapEnter(object sender)
        {
            Debug.Print("Enter tapped.");
            usr = (GHI.Glide.UI.TextBox)window.GetChildByName("userId");
            pass = (GHI.Glide.UI.PasswordBox)window.GetChildByName("passwordBox");
            
                if (current == Mode.Initial)
                {
                    txtu = usr.Text;
                    txtp = pass.Text;
                    Debug.Print("Your Password is = " + pass.Text);
                    Debug.Print("Your User ID is = " + usr.Text);

                    if (!txtu.Equals("") && wb.authentication(txtu, txtp))
                    {
                           Debug.Print("User authenticated");
                           current = Mode.Receiving;
                    }
                    else
                    {
                        Debug.Print("Please Enter Username and password");
                        current = Mode.Initial;
                    }
                    usr.Text = "";
                    pass.Text = "";
                    usr.Invalidate();
                    pass.Invalidate();
                }
                else if (current == Mode.Receiving)
                {
                    Debug.Print("enter pin");
                    //go to the email pin code enter interface
                }

            
        }
    }
}


Glad to see you got it working but some things to consider.

You have multiple functions that do the same thing. Use my idea with the Tag property of the button to hold the key value and extract this in the single function that can handle all of the number buttons. Your code will be much smaller too.

The button is passed to the function so you can know which one it was.

Secondly, because you create a string each time you call the button handler and then it is disposed of, there is going to be a lot of garbage collection. Create a global one or just work with the .Text of the TextBox directly. No need to extract to a string. See my sample from earlier.

@ Dave McLaughlin -
thanks a lot, I appreciate your comment.
Here is My function and the code works fine.
if U have any comment Please let me know.


        private void OnTap(object sender)
        {
            usr = (TextBox)window.GetChildByName("userId");
            pass = (PasswordBox)window.GetChildByName("passwordBox");
            pin = (GHI.Glide.UI.TextBox)window.GetChildByName("PINCode");
            s = (sender as GHI.Glide.UI.Button).Text;
            Debug.Print("key " + s + "tapped.");
            if ((bool)usr.Tag)
            {
                usr.Text += s;
                usr.Invalidate();
            }
            else if ((bool)pass.Tag)
            {
                pass.Text += s;
                pass.Invalidate();
            }
            else
            {
                pin.Text += s;
                pin.Invalidate();
            }
        }