473,395 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Password Characters in a DataGridView column

JB
Hi All,

I'd like to display password characters in a DataGridView column, the
same way I can do in a standard TextBox by using the PasswordChar
property (i.e.typed characters replaced by a star for instance).

Can anyone tell me how?

Thanks
JB
Sep 20 '08 #1
1 14918
JB
On 20 Sep, 14:22, JB <jb.bross...@gmail.comwrote:
Hi All,

I'd like to display password characters in a DataGridView column, the
same way I can do in a standard TextBox by using the PasswordChar
property (i.e.typed characters replaced by a star for instance).

Can anyone tell me how?

Thanks
JB
Hi All,

For those who are interested, I've figured out a "manual" solution for
this problem.
If you find a more elegant (and simpler) way to do it, please let me
know.

0) When first displaying my DataGridView (DGV) I initialise both the
Tag and Value property of the cell with the Password

1) In the EditingControlShowing event, I set the PasswordChar property
of the Editing Control
CType(DGV.EditingControl, TextBox).PasswordChar = "*"

2) In the CellValidated event (i.e. just before leaving the cell in
edit mode) I save the Password in the Cell's Tag Property
And I also clear the PasswordChar property of the EditingControl
Dim PasswordBox As TextBox = CType(DGV.EditingControl,
TextBox)
If PasswordBox IsNot Nothing Then
DGV.Rows(e.RowIndex).Cells(e.ColumnIndex).Tag =
PasswordBox.Text
PasswordBox.PasswordChar = Nothing
End If

3) In the CellFormatting event (i.e. when the cell needs to format its
value for display) I mask the content with the password char
With DGV.Rows(e.RowIndex).Cells(e.ColumnIndex)
.Value = New String("*", TryCast(.Tag, String).Length)
End With

Of course this code is only executed if the events are called for the
relevant column (i.e. the one storing the password)

JB
Sep 23 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
1
by: mark carew | last post by:
Hi, Problem - An extra column to the left (even with row headers disabled) ---------------------------------------------------------- Apologies if this posting is already in the newsgroup; but...
1
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a...
0
by: stevenhaochen | last post by:
I add a user control (a simple textbox control) to customize datagridview column to test how to add user control to datagridview. I found a weired behavior. I can not input "q", "!", "#". But I...
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
18
by: Andrus | last post by:
Marc, Thank you very much. I have issue on implementing add row properly using this. User presses down arrow in last row in grid starting adding new row. Then user changes its mind desiding...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.