StrataFrame Forum

Custom Data Type issue

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

By Ulrik Mueller - 6/17/2009

I try to use the Custom Data Type, but is getting stuck in some kind of Casting error.

I have a numeric field that is the STATUS (Active or Passive) in my Customer record.

I have made the following Enum definition

public enum StatusType
{
Aktiv = 0,
Passiv = 1
}

When using the ComboBox compononent everything is working ok.

In step two I would like to set the "Custom Data Type" in the BOM to the "StatusType" definition. Adding the datatype seems to go fine and the IDE is working correctly when adding a default value

this.tr_status = StatusType.Aktiv;

When I run the application - open the maintainance form for the CustomerBO, I receive the following error

"InvalidCastException: Specified cast is not valid"

>>>>  return (mbs2.Business.StatusType)this.CurrentRow["tr_status"];

Can someone explain me what might be wrong here, thanks!

I need to mention that when I search for the Class Type in the BOM I receive an error saying that it "Could not gather enums for Strataframe Inherited UI" and then it fails on "DevExpress.xxxxxx.v8.1".

I have v7.1 installed!!!!

Best regards
Ulrik Mueller (Denmark)

 

 

 

Exception
  Could not gather enums for MicroFour StrataFrame Inherited UI
ReflectionTypeLoadException
  Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
  LoadExceptions:
  FileNotFoundException
    Could not load file or assembly 'DevExpress.XtraEditors.v8.1, Version=8.1.1.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1' or one of its dependencies. The system cannot find the file specified.

By Trent L. Taylor - 6/17/2009

Do you receive the same error if you use the standard StrataFrame combobox? It appears that you have several potential issues here. So let's remove some things from the mix. If you use a standard StrataFrame combo, does the error persist? In other words, remove any Inherited UI elements from the formula and let's see if you the problem continues.
By Ulrik Mueller - 6/17/2009

I only use Strataframe controls 

The ComboBox control is a MicroFour.StrataFrame.UI.Windows.Forms.ComboBox

The DevExpress package is not being used in this project!!

By Trent L. Taylor - 6/17/2009

If you are referencing the MicroFour StrataFrame Inherited UI, then that is a DevExpress wrapper. This class is never touched outside of itself. So if you are receiving an exception through this class (the stack trace supplied) then the DevExpress control is in the formula at some point. You might double check that this is the case.
By Ulrik Mueller - 6/17/2009

OK - I had the Inherited UI in my project and after this have been removed from the REFERENCES I don't get the DevExpress error any more!!

I still have the error when opening the form containing the Custome Data Type

"InvalidCastException: Specified cast is not valid"

>>>>  return (mbs2.Business.StatusType)this.CurrentRow["tr_status"];   <<<<<

Do I have to set anything special on the ComboBox properties when using a CDT'ed field.  The BindingField is still pointing to the field "tr_status". (PopulationEnumName=StatusType  PopulationType=Enumeration)

Regards
/Ulrik

By Trent L. Taylor - 6/17/2009

What type is tr_Status? How is it defined in the database and what it the type in the CurrentDataTable when it comes back?
By Ulrik Mueller - 6/17/2009

In the database tr_status is a SmallInt - could that be the problem ?
By Trent L. Taylor - 6/17/2009

Yes. Enums, by default, are typed as int. You can manually cast this, though:



(mbs2.Business.StatusType)((int)this.CurrentRow["tr_status"]);
By Ulrik Mueller - 6/17/2009

It looks like it's seeing it as a SHORT in the debugger!

  this.CurrentRow["tr_status"] 0 object {short}

By Trent L. Taylor - 6/17/2009

Correct. That is what a smallint will be typed as. Just recast it as an int and you will be fine.
By Ulrik Mueller - 6/17/2009

It is now working perfectly - thanks a million.

Which DATAGRID do you recommend if grid-editing is a must ??

I have experimented with the VS standard DataGridView, but don't find it as easy to use together with the StrataFrame setup.

Again - thanks for a super support on a super framework

/Ulrik

By Trent L. Taylor - 6/17/2009

Cool Cool glad you got it going. As for a grid, there is no such thing as a fast, fun, and easy way to go. But the two I would recommend would be the Infragistics UltraGrid and the DevExpress grid, in that order. I think that the Infragistics controls, especially teh grid, are better over all.



Remember that you will have to use the BusinessBindingSource to bind to any grid.
By Trent L. Taylor - 6/17/2009

Thanks for your kind comments, too, by the way! BigGrin