How to add Textbox's PasswordChar property in PropertyGrid Control

  • Thread starter Thread starter siddhiash
  • Start date Start date
S

siddhiash

Hi Friends

I want to add PasswordChar Property which shows ****** for string which I
type in PropertyGrid Control.

Regards,
Siddharth
 
What do you mean by PropertyGrid Control, I have not see this, ( i'm
probably missing it while its staring me in the face ! ). Or do you mean you
want to use the dataGrid and want the PasswordChar properties to apply to
that ?

Please explain in more clarity.

Regards - OHM
 
Hi

There is PropertyGrid Control in VB.NET like normal property window (it is
same one). In an my application i use propertygrid control to accept
databasename, servername, password. Password property I want as **** while
typing so that it is not visible.

Regards,
Siddharth
 
Sorry, now I understand what you are trying to do. The selectObject property
is needed to be set to the object that you want to be able to set properties
for. With the textBox, there is a passwordChr as you suggest. This would
then appear in the propertyGrid.

Are you asking how to set up a similar property on a different type of
object ?

OHM
 
What you understood is right.
I want to set password field in one object same like what works in TextBox
when we set it PasswordChar = *

Regards,
Siddharth
 
OK. Now let me further understand. We have an class like so. . . . . .

Public Class MyObject

Dim p As String

Public Property pwd() As String
Get
Return p
End Get
Set(ByVal Value As String)
p = Value

End Set
End Property

End Class


'//Now we instantiate an instance of MyObject
Dim oMyObject = New MyObject

'//Now set the PropertyGrid to look at oMyObject . . .
PropertyGrid1.Text = "Property Grid"
PropertyGrid1.SelectedObject = oMyObject

Now we will see Pwd appear in the property grid and we can set it by typing
in the characters right.

OK, what you want to do is to replace the characters that you type into the
PropertyGrid itself with a character like '*'

Do I read you correctly ?, if so the only way I can think to do this is to
trap the keydown event of the PropertyGrid and do some clever work here.
When you set this property for a textBox, the textbox class replaces the
visible characters for an '*' or whatever you set it to. If you wanted to
do this for another control like a PropertyGrid ( which does not support
this method [ to my knowledge ] ) you would have to write a wrapper, and
handle it this way.

If someon else is reading this and knows of another way, please butt in and
help.


Regards - OHM
 
* "One Handed Man said:
What do you mean by PropertyGrid Control, I have not see this, ( i'm
probably missing it while its staring me in the face ! ). Or do you mean you
want to use the dataGrid and want the PasswordChar properties to apply to
that ?

'System.Windows.Forms.PropertyGrid' -- The control VS.NET uses in the
properties window.
 
Back
Top