Link to home
Start Free TrialLog in
Avatar of innominds
innominds

asked on

Binding business object (arraylist) with datagrid

I have one business class

   Public Class Firm
        Dim _FirmID As Integer
        Dim _FirmName As String
        Public Property FirmID() As Integer
            Get
                Return _FirmID
            End Get
            Set(ByVal value As Integer)
                _FirmID = value
            End Set
        End Property
        Public Property FirmName() As String
            Get
                Return _FirmName
            End Get
            Set(ByVal value As String)
                _FirmName = value
            End Set
        End Property
End Class
i am binding arraylist of objFirms - i am able to bind it. BUT question is sequence of fields are not correctly displayed in datagrid. i grid they are displayed like following

1. Firmname 2. FirmID

Dharmesh
Avatar of akumanova
akumanova

You have to sort the array before you bind it.  However there is no way to tell how your class Firm is ordering.  Therefore you have to implement your own comparison function, e.g.

Class Firm : System.Collection.IComparer
{
...
  public int Compare(object x, object y)
  {
     // write your comparison result here
  }
}

After that, you can use the sort function, e.g.

ArrayList a = new ArrayList();
... // add your firm class here

a.Sort();

Avatar of innominds

ASKER

i am not talking about record sorting but column sequence (firm id should come first then firm name should come)

Dharmesh
ASKER CERTIFIED SOLUTION
Avatar of akumanova
akumanova

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial