textbox.passwordchar is not working

  • Thread starter Thread starter EricW
  • Start date Start date
E

EricW

Hi,

In my program I create dynamicly a list of textboxes and based on how the
connected fields are defined they are masked or not.
here is the code:

txt = New TextBox
txt.Name = "lblValue" + ab.ToString("00")
txt.Margin = New Padding(5, 0, 0, 0)
txt.Font = fn
txt.BorderStyle = BorderStyle.None
txt.BackColor = Color.FloralWhite
txt.AutoSize = False
txt.Size = New Size(220, 20)
txt.MinimumSize = New Size(200, 16)
txt.MaximumSize = New Size(200, 180)
txt.WordWrap = True
txt.Multiline = True
txt.ReadOnly = True
txt.PasswordChar = GetMasked(dsDefs, rw, ab)
txt.Text = rw(ab)
pnItem.Controls.Add(txt)
pnItem.Controls(txt.Name).Location = New Point(150, ay)
ad = New Size
ad = pnItem.Controls(txt.Name).PreferredSize
pnItem.Controls(txt.Name).Size = ad

The function GetMasked checks if the text should be masked or not. It
returns chrW(42) if it needs to be masked, nothing if not.

Unfortunatly this is not working. The text is not masked.
Even when I comment out the GetMasked function and replace it with chrW(42)
then it still doesn't mask my text.

What am I doing wrong here?
Must the passwordchar property be set before another property?

pls help.

rg,
Eric
 
Hi Eric,

I'm afraid I could not reproduce your problem. Your code worked as expected
both in C# and VB.Net. As far as I know there is no order requirement for
setting PasswordChar. If you set it, you specify masking.

If you run your code in a clean solution. Does it still fail to mask?
 
I assume that means I have to click "Clean Solution" in the build menu?

Did that, but still no masking as it should be.

I have created my own kind of masking (using tag to store the real text and
filling text with *)

I'll see later what happens on the user's pc.

thanks though.

rg,
Eric



Morten Wennevik said:
Hi Eric,

I'm afraid I could not reproduce your problem. Your code worked as
expected
both in C# and VB.Net. As far as I know there is no order requirement for
setting PasswordChar. If you set it, you specify masking.

If you run your code in a clean solution. Does it still fail to mask?

--
Happy Coding!
Morten Wennevik [C# MVP]


EricW said:
Hi,

In my program I create dynamicly a list of textboxes and based on how the
connected fields are defined they are masked or not.
here is the code:

txt = New TextBox
txt.Name = "lblValue" + ab.ToString("00")
txt.Margin = New Padding(5, 0, 0, 0)
txt.Font = fn
txt.BorderStyle = BorderStyle.None
txt.BackColor = Color.FloralWhite
txt.AutoSize = False
txt.Size = New Size(220, 20)
txt.MinimumSize = New Size(200, 16)
txt.MaximumSize = New Size(200, 180)
txt.WordWrap = True
txt.Multiline = True
txt.ReadOnly = True
txt.PasswordChar = GetMasked(dsDefs, rw, ab)
txt.Text = rw(ab)
pnItem.Controls.Add(txt)
pnItem.Controls(txt.Name).Location = New Point(150, ay)
ad = New Size
ad = pnItem.Controls(txt.Name).PreferredSize
pnItem.Controls(txt.Name).Size = ad

The function GetMasked checks if the text should be masked or not. It
returns chrW(42) if it needs to be masked, nothing if not.

Unfortunatly this is not working. The text is not masked.
Even when I comment out the GetMasked function and replace it with
chrW(42)
then it still doesn't mask my text.

What am I doing wrong here?
Must the passwordchar property be set before another property?

pls help.

rg,
Eric
 
EricW said:
I assume that means I have to click "Clean Solution" in the build menu?

That might have worked as sometimes library references get stuck etc. What
I had in mind was creating a new windows application with nothing but a panel
and the minimum of code. Basically just add a default TextBox and set only
the PasswordChar property. If the passwordchar is displayed in this project,
then your original project may have some code in between what you have shown
and what is displayed on screen. If the passwordchar is still missing, you
may need to repair/reinstall visual studio/.net framework. You could try a
C# project, but even if it works in C# the vb.net assemblies may be corrupt.
 
Back
Top