[RESOLVED] [2005] Load all system Cursors into Combo
Hello again everyone! :wave:
Is it possible to use a For loop to load all the system cursors / VB.NET cursors into a combobox. I tried the following (which obviously couldn't work - but it's based on a similar way I load all the system fonts - FontFamilies)
Code:
Dim cC As Cursor
For Each cC In Me.System.Windows.Forms.Cursor
cboCursors.Items.Add(cC.Name)
Next
Any advice?
Re: [2005] Load all system Cursors into Combo
With a little Reflection...
Code:
Imports System.Reflection
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each p As PropertyInfo In GetType(Cursors).GetProperties
If (p.PropertyType Is GetType(Cursor)) Then
ComboBox1.Items.Add(p.Name)
End If
Next
End Sub
End Class
Re: [2005] Load all system Cursors into Combo
Re: [2005] Load all system Cursors into Combo
OOPs, I forgot, how would I set the cursor from this loaded list?
Just made anrray - duh!
Code:
Private CurseInt As Integer 'keeps track of selected item
Private CursorArray() As Cursor 'cursor array
'In Form Load
ReDim CursorArray(cboCursors.Items.Count)
CursorArray(0) = Cursors.AppStarting
CursorArray(1) = Cursors.Arrow
CursorArray(2) = Cursors.Cross
CursorArray(3) = Cursors.Default
CursorArray(4) = Cursors.Hand
CursorArray(5) = Cursors.Help
CursorArray(6) = Cursors.HSplit
'etc. until all 28 cursors are stored in the array
'in combo selectedindexchanged event
CurseInt = (cboCursors.SelectedIndex) 'if sel > -1
'then in button
Me.Cursor = CursorArray(CurseInt)
It works, but isn't there perhaps an easier way?