Displaying a password as a ListView item

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmF5IE1pdGNoZWxs?=

    Displaying a password as a ListView item

    Hello,

    I would like to keep passwords in a ListView item but have them display as
    asterisks or som other arbitrary character. This is easy in a text box by
    settin the appropriate attribute but there doesn't appear to be such an
    attribute for list view items. I have several klugey ideas for how to
    accomplish this, for example, using an extra hidden item in the ListView, but
    I just wanted to chek on this group first to see if there was a cleaner way.

    Thanks,
    Ray
  • Family Tree Mike

    #2
    Re: Displaying a password as a ListView item

    I did not test this thuroughly, but I think it works as you want.
    listView1 needs to be set to OwnerDraw = true.

    public Form1()
    {
    InitializeCompo nent();
    listView1.DrawI tem += new
    DrawListViewIte mEventHandler(l istView1_DrawIt em);
    }

    void listView1_DrawI tem(object sender, DrawListViewIte mEventArgs e)
    {
    // Draw the item text for views other than the Details view.
    if (listView1.View != View.Details)
    {
    string s = e.Item.Text;
    e.Item.Text = "************** *************** ".Substring (0, s.Length);
    e.DrawText();
    e.Item.Text = s;
    }
    }

    "Ray Mitchell" <RayMitchell_NO SPAM_@MeanOldTe acher.comwrote in message
    news:AE11708B-9DC5-4917-B571-2E58E3254D5F@mi crosoft.com...
    Hello,
    >
    I would like to keep passwords in a ListView item but have them display as
    asterisks or som other arbitrary character. This is easy in a text box by
    settin the appropriate attribute but there doesn't appear to be such an
    attribute for list view items. I have several klugey ideas for how to
    accomplish this, for example, using an extra hidden item in the ListView,
    but
    I just wanted to chek on this group first to see if there was a cleaner
    way.
    >
    Thanks,
    Ray

    Comment

    Working...