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

Welcome Forums General PowerShell Q&A 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

 
Participant
2 years, 10 months ago.

  • Author
    Posts
  • #32327

    Participant
    Points: 0
    Rank: Member

    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.windows.forms.listbox
    $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.Controls.Add($listBox1)
    
    $form.ShowDialog() | Out-Null
    

    here it a link to the screen shot
    https://copy.com/dIxqL4gdBFo1WnSp

  • #32328

    Member
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    Ahh. Thanks!

The topic ‘listbox has dotted line inside it which I don't want to show’ is closed to new replies.