I’m trying to have a particular column in a list box be a password field with the entered password obscured by dots like when a textfield’s password property is set to true.
I haven’t been able to successfully do this. I try to grab the ActiveCell and then type cast it as a text field and set the password property to true. But when I do that, I am no longer able to edit the cell.
I’m sure I can eventually figure it out but I figured it might be faster to ask here.
Here is one idea: Send the clear text password to celltag, In the listbox, create a string of unicode character 2B24 (a large circle). If the listbox is populated from a file or other source programmatically, it is easy. If you type into the listbox, then the keydown event can be used to track what is being typed and perform the character replacement and update of celltag.
[quote=278961:@Kem Tekinay]Use TextChange, not KeyDown though.
Jon, do you mind if it’s plain text only while editing?[/quote]
Well, maybe not. But I’d rather have it blacked out while editing. If you put it in KeyDown as Louis suggested, it can be done, you just have to do much more to manage it…
by the way, michel and I find a workaround,
you must install the special code into the window menu handler
if you put it in the control menu hanlder, it does not get fired
if this can help you in this particular case ?
[quote=278981:@Jean-Yves Pochez]I would also like it …
by the way, michel and I find a workaround,
you must install the special code into the window menu handler
if you put it in the control menu hanlder, it does not get fired
if this can help you in this particular case ?[/quote]
Problem is that then IF, like the IDE, you want to have different actions for the Window getting a “Paste” vs a text field getting a “paste” you’re sort of stuck
And you certainly cant reconfigure the active cell to be a password one
That report should have been an FR - not a bug report - as the listbox is actually behaving as designed
The design prevents you from doing the things you are trying to do (but its not a regression nor new)
This was actually very easy to do and once I figured it out, simple to implement. Using CellTextChanged is way easier than attempting to use the CellKeyDown event as you don’t need to account for things like backspace, etc. And you do NOT see the plain text characters when doing this.
One IMPORTANT thing to note: When you change the cell’s text inside the CellTextChanged event, you MUST implement a way to prevent going into an infinite loop as when you change the text to the dots, it causes the event to fire again.
Finally, I used u25CF for the dots as it is a smaller character than u2B24.
[code] If column = 1 Then
Dim cellText as string = me.cell(row,1) // Grab the text of the field as it's easier to work with than calling the cell method each time
If cellText.Right(1) <> &u25CF and cellText <> "" Then // Only update if the last character is NOT a dot and we actually have text in the field.
Dim DotPosition as integer = CountFieldsB(cellText, &u25CF)-1 // Count the number of dot characters (need to use -1 as the method counts the fields not the dots
me.cellTag(row,column) = me.cellTag(row,column)+CellText.Right(CellText.Len-DotPosition) // Build the cell tag
// now build the dots to fill in the field
Dim dots as string
For i as integer = 1 to cellText.Len
dots = dots+&u25CF
Next
// Replace the text with the field
me.ActiveCell.Text = dots
End If
try pressing the left arrow & type (on OS X at least)
should be able to type in plain text except for the last char which will have a
basically as long as the insertion point isn’t at the end this should allow plain text typing
[quote=279231:@Norman Palardy]try pressing the left arrow & type (on OS X at least)
should be able to type in plain text except for the last char which will have a
basically as long as the insertion point isn’t at the end this should allow plain text typing
just FYI[/quote]
Yeah, you are correct…didn’t consider that case…
I’ll figure it out tomorrow. Getting late now. I have an idea how to do it…
The method you posted above seems to miss characters. The following worked better (for me anyways):
Dim cellText As String = Me.cell(row,1)
Dim cnt, len As Integer
len = cellText.Len
cellText = ""
For cnt = 1 To Len
cellText = cellText + &u25CF
Next cnt
Me.ActiveCell.Text = cellText