Listbox item padding or spacing

How can I add spacing between items in a listbox?

I am using it on a touchscreen and increased the font but it would be nice to have spacing between each item.

Thanks,
Scott

You’d have to draw it yourself or just insert a null value between lines. If learning PS, the listbox is a difficult control to start with:D

I’d go with a datagridview. Bonus, if you load the data as a datatable you can easily filter the columns by year,song,album etc.

Thanks. I am using the Datagridview to display the results and was using the Listbox to display a list of years and genres that you could Multi-Select, then the results would display in the datdridview. As far as I can tell, you cannot multi-select from a datagrid view. I can use a series of checkboxes for the years and genres but it was much cleaner with the listbox.
Another thing I just noticed, I am not using scrollbars for anything but rather buttons to scroll, and it does not look like the listbox can scroll via a button without selecting something from the list.

Any ideas?

Thanks,
Scott

Here’s an example of filtering a datagrid. you can easily substitute a combobox for years or genres.


$form1_Load={
	
#	$Data = 1 .. 25 | %{
#		
#		[pscustomobject]@{
#			
#			songname = 'song' + $_
#			genre = 'rap','rock','classical','jazz' | get-random
#			year = [string](1980..2017 | Get-Random)
#			index = [string](100..200 | get-random)
#		}
#	
#	}
	
	$script:Itunes = New-Object -ComObject iTunes.Application
	$script:LibrarySource = $Itunes.sources.ItemByName('Library')
	$script:libraryplaylist = $librarysource.playlists.itembyname('Dan''s Music')
	$script:tracks = $libraryplaylist.tracks | select name, album, artist, genre, @{n = 'year'; e = { [string]$_.year }}
	
	$script:dt = ConvertTo-DataTable -InputObject $tracks
	$datagridview1.DataSource = $dt
	
}



$textbox1_TextChanged={
	
	$filter = $textbox1.text
	$DT.defaultview.rowfilter = "year like '%$filter%' or genre like '%$filter%'"
	
	
}



Thanks for the example! I can get it to filter, I was more looking at filtering on multiple at a time . I want to be able to select multiple genres and years and have it show the results (like 80s, 90’s and Rock). I have this working with the listbox just fine (and had it working with checkboxes), I was just hoping to be able to make the items in the listbox more touch friendly. I increased the font but was hoping to put a little more space between each one and be able to scroll but that does not seem possible.

easy, use comboboxes or listboxes. Change the filter to AND or OR based on if selected.

Like so. The function is mininiscule now but I always like to start off with them if I anticipate it getting more complex down the road. You could supply multiple parameters and build your filter inside the function then pass it to the rowfilter.

function get-year {
	
param($year)
	
	switch ($year) {
		
		1980{'198' }
		1990{'199'}
		2000{'200' }
		2010{'201'}
		
	}
}

$form1_Load={
	
	$tracks = 1 .. 25 | %{
		
		[pscustomobject]@{
			
			songname = 'song' + $_
			genre = 'rap','rock','classical','jazz' | get-random
			year = [string](1980..2017 | Get-Random)
			index = [string](100..200 | get-random)
		}
	
	}
	
	$script:dt = ConvertTo-DataTable -InputObject $tracks
	$datagridview1.DataSource = $dt
	
}


$combobox1_SelectedIndexChanged = {

	$genrefilter = $combobox1.selecteditem
	$DT.defaultview.rowfilter = "genre like '%$genrefilter%'"
	
}


$combobox2_SelectedIndexChanged = {
	
	$yearfilter = get-year $combobox2.SelectedItem
	$genrefilter = $combobox1.selecteditem
	
	if ($combobox1.SelectedIndex -gt 0) {
		$DT.defaultview.rowfilter = "genre like '%$genrefilter%' and year like '%$yearfilter%'"
	}
	
}