StrataFrame Forum

My ComboBox is not seeing my enum

http://forum.strataframe.net/Topic19437.aspx

By Marcia G Akins - 9/16/2008

Hi All.

I must have taken my stupid pills today because this should be simple.

My enum is defined in the form like this:

public enum Months : int { January = 1, February = 2, March = 3, April = 4, May = 5, June = 6, July = 7, August = 8, Spetember = 9, October = 10, November = 11, December = 12 };

The combo box is set up like this:

this.cboyearend_mth.BindingField = "yearend_mth";

this.cboyearend_mth.BusinessObject = this.boPlan_hdr;

this.cboyearend_mth.BusinessObjectEvaluated = true;

this.cboyearend_mth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

this.cboyearend_mth.FormattingEnabled = true;

this.cboyearend_mth.Location = new System.Drawing.Point(120, 162);

this.cboyearend_mth.Name = "cboyearend_mth";

this.cboyearend_mth.ParentContainer = this;

this.cboyearend_mth.PopulationType = MicroFour.StrataFrame.UI.ListPopulationType.Enumeration;

this.cboyearend_mth.PopulationEnumName = "Trinity.Forms.Months";

this.cboyearend_mth.Size = new System.Drawing.Size(121, 21);

this.cboyearend_mth.TabIndex = 13;

But when I run the form, nothing shows up in the drop down list. I have no idea what the problem could be.

By Bill Cunnien - 9/16/2008

Try changing:

this.cboyearend_mth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

to

this.cboyearend_mth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;

Any difference?

By Marcia G Akins - 9/16/2008

Bill Cunnien (09/16/2008)
Try changing:

this.cboyearend_mth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

to

this.cboyearend_mth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;

Any difference?

No - still no items in the list

By Marcia G Akins - 9/16/2008

OK - I stepped thru the code in Combobox.Requery() and I am seeing that this line in the GetReferencedAssemblies() method:

'-- Try to just get the type before moving on

loType = Type.GetType(TypeName, False, True)

returns null.

It seems that it cannot find the enum. What would cause this?

By Marcia G Akins - 9/16/2008

OK - Got it solved. The enum was defined in the wrong place and that is why the framework couldn't see it.

Thanks for trying to help.

By Edhy Rijo - 9/16/2008

Hi Marcia,

  1. Exit VS and open the solution again and re-build, then see if it works. 
  2. If not, try creating the Enum in a separate class file, re-build, then assign the enum to the combobox again and test.
By Bill Cunnien - 9/16/2008

I second Edhy's suggestion about placing the enums in a separate class file.  Glad you got it going!
By Marcia G Akins - 9/16/2008

Edhy Rijo (09/16/2008)
Hi Marcia,

If not, try creating the Enum in a separate class file, re-build, then assign the enum to the combobox again and test.

That is on my list. So far, I have only 2 enums in the project, so it will not be too hard to refactor this later after I have wowwed the client with how quick I am Smile

By Trent L. Taylor - 9/17/2008

Glad you found your issue.  The only time that you will generally have an issue with the VS DTE not "seeing" an enum when you know with all of your being that it should is when the AppDomain of the DTE is holding on to an older version of an assembly and will not load the newly built assembly housing the enum.  This is common if the assembly is stored in the GAC and from time to time VS just doesn't want to let go for unknown reasons.  But at any rate, it looks as though you were already on top of it Smile
By Peter Denton - 9/17/2008

G'day

A technique I use when I'm trying to set up a lookup on an enum, is to create a variable of the enum type, then get the type of the variable, and the AssemblyQualifiedName of the type, e.g.

Dim fred As CloseReason = CloseReason.FormOwnerClosing

MsgBox(fred.GetType.AssemblyQualifiedName)

Usually I do this in the debugger, put a breakpoint on the Msgbox line, put fred.GetType.AssemblyQualifiedName in the Watch and copy the literal value from the Watch to where I want the enum name. Especially useful wher it isn't your enum that you're trying to use.

Hope this helps. I also reccomend all the enums in one class.

Peter

By Marcia G Akins - 9/18/2008

Peter Denton (09/17/2008)
G'day

Hope this helps. I also reccomend all the enums in one class.

Peter

 

Done yesterday Smile