Enum GetValues/GetNames .. is this odd?

  • Thread starter Thread starter smith
  • Start date Start date
S

smith

It's a time saver to "bind" .Net enums to list and comboboxes and all the
samples out there seem to use GetNames and GetValues pretty interchangeably.

So I was wondering what the logic is to the System.Drawing.RotateFlipType
enumeration.

GetNames and GetValues results don't seem to synch up and binding to
GetValues seems to create duplicates of some elements while"losing" others,
and I haven't seen any mention of why that might be.

To see it just drop a couple of tall listboxes on a form and in the load
add:

ListBox1.DataSource = System.Enum.GetNames(GetType(RotateFlipType))
ListBox2.DataSource = System.Enum.GetValues(GetType(RotateFlipType))

Or dump the same to Output:

Dim arValues as String() = System.Enum.GetValues(GetType(RotateFlipType))
Dim arValues As RotateFlipType() =
System.Enum.GetValues(GetType(RotateFlipType))

For i As Integer = 0 To arNames.Length - 1
Debug.WriteLine(arNames(i) & vbTab & arValues(i).ToString)
Next

yields:

Rotate180FlipXY RotateNoneFlipNone
RotateNoneFlipNone RotateNoneFlipNone
Rotate90FlipNone Rotate270FlipXY
Rotate270FlipXY Rotate270FlipXY
Rotate180FlipNone RotateNoneFlipXY
RotateNoneFlipXY RotateNoneFlipXY
Rotate270FlipNone Rotate90FlipXY
Rotate90FlipXY Rotate90FlipXY
RotateNoneFlipX Rotate180FlipY
Rotate180FlipY Rotate180FlipY
Rotate90FlipX Rotate270FlipY
Rotate270FlipY Rotate270FlipY
Rotate180FlipX RotateNoneFlipY
RotateNoneFlipY RotateNoneFlipY
Rotate270FlipX Rotate270FlipX
Rotate90FlipY Rotate270FlipX

it's not that there's no one to one relation, but that GetValues returns the
odd duplcate text values. Is it just something about this particular enum
or is this logical and do others that I've not seen yet also do this?

Just wonderin'

smith
kirkland, wa
www.smithvoice.com
 
Ahem, bad paste. Those arrays are of course:

Dim arNames As String() = _
System.Enum.GetNames(GetType(RotateFlipType))

Dim arValues As RotateFlipType() = _
System.Enum.GetValues(GetType(RotateFlipType))

....
 
Oy. I just didn't wrap my head fully around the degrees and flippage:
http://thedotnet.com/howto/work148254.aspx

Why do we always figure things out just two tries after we've publicly said
that we couldn't do it? And why is it a sliding scale so that you have to
admit it first and only then do the extra tries work?

The rules of this universe were created by a trickster.

smith
 
Back
Top