I am not sure about availability of ItemTemplate in WinForms DataGridView.
Also, I am not sure about KeyPress Event being the best Event for this purpose. nevertheless,
To convert content of your text box (named 's' in your example) into a string of 'PasswordChar', you can use the following code:
.
if (s.Text.Length > 0)
{
string strToShow="";
foreach(char ch in s.Text.ToCharArray())
{
strToShow+="*";
}
}
s.Text=strToShow;
And I hope you had stored the original value of keyStroke somewhere so that you can have original password rather than this 'PasswordString'. Also, before applying the above code, make sure you have handled BackSpace/Delete/Enter/UnwantedCharactersFromPasswordCriteria .