StrataFrame Forum

Como carregar imagens no ListView

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

By Marcio Valerio Silva - 1/25/2011

How Do I load images in the Strata Frame ListView Component?

I Tryed:

Private void listView1_RowPopulating(MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs e)

{
MesasBo loBO = new MesasBo();
loBO = e.BusinessObject;
}



But in C# don´t work "loBO = e.BusinessObject" as the documentation method example in VB.

I somebody know how please answer my question.

thanks!

----------------------------------------------------------------------------------

Como carregar imgens no ListView do Strata Frame os dados já sei como fazer mas gostaria de carregar imagens definidas no cadastro.

Eu até tentei o exemplo da documentação conforme acima porém não funcionou no c#.

Se alguém souber como fazer responda-me por favor.


Obrigado!
By Marcio Valerio Silva - 1/26/2011

Sorry but I Really need this information!

In the Documentation has this sample:

Private Sub ListView1_RowPopulating( _
                ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) _
                Handles ListView1.RowPopulating
               
    '-- Establish locals
    Dim loBO As CustomersBO
   
    '-- Get the reference to the business object
    loBO = e.BusinessObject
    If loBO.cust_gender = 0 Then
        '-- The customer is a male, set the background color to blue
        '   and set the image key to the boy icon
        e.RowBackColor = Drawing.Color.LightBlue
        e.ImageKey = "boy.ico"
    Else
        '-- The customer is a girl, set the background color to pink
        '   and set the image key to the girl icon
        e.RowBackColor = Drawing.Color.Pink
        e.ImageKey = "girl.ico"
    End If
   
    '-- The fourth column has been configured to PopulateThroughEvent
    If loBO.cust_email.Length > 0 Then
        '-- We have an email in the record
        e.Values(3).DisplayValue = loBO.cust_email
    Else
        '-- We don't have an email for this customer
        e.Values(3).DisplayValue = "unavailable"
    End If
End Sub
and I translated to c#:

private void listView1_RowPopulating(MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs e)
{
MesasBo mesas = new MesasBo();
mesas = e.BusinessObject;
}
and I get this error:

Error 10 Cannot implicitly convert type 'MicroFour.StrataFrame.Business.BusinessLayer' to 'M2BusinessObjectLibrary.MesasBo'. An explicit conversion exists (are you missing a cast?) D:\Projetos\Business Enterprise\M2FoodService\Form1.cs 65 24 M2FoodService


I need a quick solution for this problem.

By Ivan George Borges - 1/26/2011

Have a look at this post:

http://forum.strataframe.net/FindPost16905.aspx
By Trent L. Taylor - 1/27/2011

You can't have an explicit conversion in C# if you don't have the operator defined.  In this example, the explicit conversion cannot happen between a BusinessLayer and your BO type.  Just cast it:

MesasBo mesas;
mesas = (MesasBo)e.BusinessObject;


Also, don't create a new instance of mesas because you are pushing a reference to that variable.  So you don't want to create an instance of it first, that will just cause a potential memory leak since you didn't dispose of the object.  Though no handlers were created either, so it would most likely have cleaned itself up through the collector.  But this is still not a good way to setup a variable that will have a reference pushed into it.