locked
ToolStripTextBox Passwords? RRS feed

  • Question

  • how can i set for my form ToolStripTextBox Hidden true text and replace for * ?

     

    i only see PasswordChar in normal TextBox Sad

     

    C#

     

    thanks

     

     

    Sunday, August 19, 2007 11:22 PM

Answers

  • Hi Knive1,

     

    Customizing your own ToolStripControlHost will help you to achieve this. But these is a simple way to do this. See my sample below:

    Code Snippet

     namespace ToolStripControlHostP

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

            }

     

            private void Form1_Load(object sender, EventArgs e)

            {

                if (this.toolStripTextBox1.Control is TextBox)

                {//important

                    TextBox tb = this.toolStripTextBox1.Control as TextBox;

                    tb.PasswordChar = '*';

                }

            }

     

            private void button1_Click(object sender, EventArgs e)

            {

                MessageBox.Show(this.toolStripTextBox1.Text);

            }

        }

    }

     

    Hope this helps.

    Best regards.

    Thursday, August 23, 2007 2:17 AM
  • Because the framework doesn't come with one out of the box you might try building your own and wrapping it in a ToolStripControlHost control.

    Sunday, August 19, 2007 11:28 PM

All replies

  • Because the framework doesn't come with one out of the box you might try building your own and wrapping it in a ToolStripControlHost control.

    Sunday, August 19, 2007 11:28 PM
  • any example?

     

    Monday, August 20, 2007 2:06 PM
  • Hi Knive1,

     

    Customizing your own ToolStripControlHost will help you to achieve this. But these is a simple way to do this. See my sample below:

    Code Snippet

     namespace ToolStripControlHostP

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

            }

     

            private void Form1_Load(object sender, EventArgs e)

            {

                if (this.toolStripTextBox1.Control is TextBox)

                {//important

                    TextBox tb = this.toolStripTextBox1.Control as TextBox;

                    tb.PasswordChar = '*';

                }

            }

     

            private void button1_Click(object sender, EventArgs e)

            {

                MessageBox.Show(this.toolStripTextBox1.Text);

            }

        }

    }

     

    Hope this helps.

    Best regards.

    Thursday, August 23, 2007 2:17 AM
  • thanks that solve my problem Big Smile

    Thursday, August 23, 2007 11:04 AM