listbox has dotted line inside it which I don't want to show

This topic contains 2 replies, has 2 voices, and was last updated by  Shane Lindberg 2 years, 7 months ago.

  • Author
  • #32327

    Shane Lindberg

    here is my code for a listbox. when you click on the form it shows a dotted outline at the top of the listbox. I would like to remove it.

    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
    $form = New-Object System.Windows.Forms.Form
    $form.Text = "test"
    $drawing_size = New-Object System.Drawing.Size
    $drawing_size.Width = 350
    $drawing_size.Height = 300
    $form.Size = $drawing_size
    $listbox1 = New-Object
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 301
    $System_Drawing_Size.Height = 212
    $listBox1.Size = $System_Drawing_Size
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 13
    $System_Drawing_Point.Y = 13
    $listBox1.Location = $System_Drawing_Point
    $form.ShowDialog() | Out-Null

    here it a link to the screen shot

  • #32328

    Dave Wyatt

    It's doing that because the list box has focus; the dotted line is showing you where your keyboard will start doing stuff if you press space, tab, etc. If your form has other elements, you can give one of those focus instead, but in this small example where the ListBox is your only control, you can just set the list box's TabStop property to False to get a similar result:

    $listbox1.TabStop = $false
  • #32329

    Shane Lindberg

    Ahh. Thanks!

You must be logged in to reply to this topic.