Setting up a grid / BO with related fields


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Guys,

Yes - it all worked as advertised (in the SF Help) - thanks a lot. The only issue I had (being a .Net newbie) was how to get all my (seven off) custom fields into GetCustomBindablePropertyDescriptors. This turned out to be easy but I thought I would post the code in this thread in case someone else has similare issues. It hasn't sunk in what yet as to the special meaning of the swiggly braket but my offsider pointed out what I needed to do.


   Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

        Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "Product", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "BinCode", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ReceiveBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "FleshingBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ShortTermBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "TanningBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "OrderNo", GetType(boPUNAllocatedToFleshBatch))}
    End Function

Cheers, Peter

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yeah, that whole curly bracket thing confused the heck out of me at first too. It is related to arrays. First lets look at some simple array examples:



' An array of strings

Dim names As String()

' An array of integers

Dim ages As Integer()

'An array of FieldPropertyDescriptors

Dim descriptors As FieldPropertyDescriptor()




You probably already figured out this is how you dim an array. Of course, then you have to Redim it to the correct size and then add each item, which is a pain lots of times:



' Dim an array of names

Dim names As String()

'...later in code, size and fill the array

Redim names As String(2)

names(0) = "Joe"

names(1) = "John"




As you likely know, with other types of variables, you can just set the value or initialize the variable when you dim it. But how do you do that with an array? Arrays need to be sized before adding elements to them and the elements are added by index. That is were the curly brackets come into play. The curly brackets are array initializers and allow you set the initial values of the array:



' An array of strings

Dim names As New String() {"Joe","Bob","Sam"}

' An array of integers

Dim ages As Integer() {23, 34, 56}

'An array of

Dim descriptors As FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"Product", GetType(boPUNAllocatedToFleshBatch)), _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"BinCode", GetType(boPUNAllocatedToFleshBatch))}




So, the curly brackets simply allow you to initialize the array with values when you create the array. Note that you do NOT set the size of the array when you use an initializer (the curly brackets). You can also use initializers with multi dimension arrays. In that case, you need to set the rank of the array, but not the size:



' Array of names, first in 0 and last in 1

Dim names As String(,) { {"Joe", "John"}, {"Smith","Simpson"} }




Hope that helps!
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Greg,

Thanks for taking the time to write Arrays 101 - your comments are indeed very helpful.

Cheers, Peter

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad that helped BigGrin
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Greg,

Thanks for such a detail response, it helps me a lot.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search