Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Password field in the DynamicallyAutoDetectDataTypeColumn

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Password field in the DynamicallyAutoDetectDataTypeColumn
Link Posted: 03-Jul-2006 00:07
Hi,

What type the value in the DynamicallyAutoDetectDataTypeColumn must have in order the grid to interprete it as password and display and edit it as password field?

It is possible somehow to reuse password editing control functionality in the DynamicallyAutoDetectDataTypeColumn?

Thank you.
Link Posted: 03-Jul-2006 04:30
1. To display password protected data you can override Column.GetTextValue and replace real symbols by password symbol.
2. Override OnEditorSetup to specify password char for editor:
[c#]
private char passwordChar = '*';
private bool inGettingValueForEditor = false;
public override string GetEditValue(NodeBase node)
{
  inGettingValueForEditor = true;
  try
  {
    return GetTextValue(node);
  }
  finally
  {
    inGettingValueForEditor = false;
  }
}
public override object GetValue(NodeBase node)
{
  object val = base.GetValue(node);
  //translate value if is in editing
  if (!inGettingValueForEditor && val != null && val is string)
  {
    string strval = val as string;
    if (strval.Length > 0 && passwordChar != (char)0)
    {
      val = new string(passwordChar, strval.Length);
    }
  }
  return val;
}

protected override void OnEditorSetup(TextBox editor)
{
  base.OnEditorSetup (editor);
  if (passwordChar != (char)0)
    editor.PasswordChar = passwordChar;
}