StrataFrame Forum

Two quick questions...

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

By Ulrik Mueller - 6/18/2009

1. I'm using ComboBox with enumerated lists.  How do I override the enumeration text in the ComboBox dropdownlist ?

2. I'm trying to work with a BO entirely from code (C#) - creation, calling a method on the BO and finally disposing.  I am getting blind onto the correct way of doing this.  HELP......

Looking forward to hear from you all ;-)

Regards
Ulrik

By Edhy Rijo - 6/18/2009

Hi Ulrik,



Ulrik Mueller (06/18/2009)
1. I'm using ComboBox with enumerated lists. How do I override the enumeration text in the ComboBox dropdownlist ?




For this you can use the < EnumDispayValue() > from the MicroFour.StrataFrame.Tools, here is sample in VB:





Imports MicroFour.StrataFrame.Tools



Public Enum eMailSendFormat As Integer

< EnumDisplayValue("Acrobat (PDF)") > _

Acrobat_PDF = 1



< EnumDisplayValue("Comma Separated Values (Windows-CSV)") > _

CSV = 2

End Enum





2. I'm trying to work with a BO entirely from code (C#) - creation, calling a method on the BO and finally disposing. I am getting blind onto the correct way of doing this. HELP......




I am not sure I totaly understand your request here, but here is sample in VB of how to use a SF BO:



Using bo As bizItems = New bizItems

bo.FillByPrimaryKey(pPK_Items)

If bo.Count = 1 Then

Return bo.ItemName

Else

Return String.Empty

End If

End Using


By Greg McGuffey - 6/18/2009

C# versions:



To change text displayed in an SF combo that is loaded from an enum, set an attribute on each item within the enum:



using MicroFour.StrataFrame.Tools



public enum eMailSendFormat {

  // This will now display "Acrobat (PDF)" in combo

  [EnumDisplayValue("Acrobat (PDF)")]

  Acrobat_PDF = 1;



  // This will now display "Comma Separated Values (Windows-CSV)" in combo

  [EnumDisplayValue("Comma Separated Values (Windows-CSV)")]

  CSV = 2;

}




The 'using' statement in C# (Using in VB.NET) are used to ensure that disposable objects get disposed. I.e. when the using block is exited, the item is disposed. This occurs whether the code runs it course, you break out of it or an exception occurs within the block.



using CustomerBO customers = new CustomerBO() {

  customers.FillByCity("Munich");

} // calls customers.Dispose() automatically when this block exits
By Ulrik Mueller - 6/18/2009

Thanks for the assist - it is working perfectly!   Watch out, i am sure that i'll be back soon with another "simpel" question!

Best regards
Ulrik

By Greg McGuffey - 6/18/2009

Any time! BigGrin
By Edhy Rijo - 6/18/2009

Ulrik Mueller (06/18/2009)
Thanks for the assist - it is working perfectly!




Not a problem, glad it worked and it was easy for you. Cool



Greg, thanks for the C# translation Hehe
By Trent L. Taylor - 6/19/2009

Good answers, guys! Thanks!