Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
I've looked in the help and can't find a list collection of all the columns/properties that were mapped from table to BO.
I would like to populate a combobox.Items collection with this list. Can you tell me where I can get this list?
This might be a .Net question, but an answer would help a lot!
Thanks!
..ßen
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
Ok, there is a list property Fieldnames of each BO. I tried to iterate through it but no luck: foreach (string f in BO.StoreBO.StoreBOFieldNames)
{
comboBox1.Items.Add(f);
}
}
..ßen
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
never mind the last bracket, cut & paste mistake!
..ßen
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
A BO has a property called AllFIeldsList that contains all of the fields that belong to the BO. You can enumerate it like this: '-- Establish Locals Dim lcAllFields As String = "" For Each lcField As String In Me.MyBO.AllFieldsList.ToArray() lcAllFields &= lcField & ControlChars.CrLf Next MsgBox(lcAllFields)
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
Thanks Trent;
I'm glad you gave me that code snippet. I'd have missed the "ToArrey" method!
..ßen
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
You shouldn't have to use the ToArray() to do a For Each on the AllFieldsList... it already implements the IEnumerable and IEnumerable<string> interfaces. Also, if you need any of the other collections, you can check out the shared constructor for a business object (located in the designer file) and you can see the collections that are created for each BO class, such as FieldLengths, FieldDbTypes, FieldNativeDbTypes, AllFieldsList, etc.
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
You shouldn't have to use the ToArray() to do a For Each on the AllFieldsList... it already implements the IEnumerable and IEnumerable interfaces. Ben, I wanted to ask Trent that question why I need to use ToArray(). However, I was trying to get that list, put it into a ComboBox and have the user select the field and I'll do Sort on it. At first I tried to assign BO.AllFieldList to ComboBox.Items and didn't like it and I ended up doing the following way: foreach (string f in storeTaxBO.AllFieldsList.ToArray()) { comboBox1.Items.Add(f); } How else could I have done this but using ForEach? Thanks!
..ßen
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
Also, if you need any of the other collections, you can check out the shared constructor for a business object (located in the designer file) and you can see the collections that are created for each BO class, such as FieldLengths, FieldDbTypes, FieldNativeDbTypes, AllFieldsList, etc. I just got to see under the hood. Very nice! I still don't understand why I couldn't assign from that list to ComBox.Items? In Delphi, I can make that assignment without any problem!
..ßen
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
The items collection is special... you can manually add to it, but it's readonly, so you cannot create a new ComboBox.ItemCollection and set it to the value. You can, however, set it as the DataSource of the ComboBox. myCombo.DataSource = myBo.AllFieldsList; Should work the way you want it to. If the collection contains complex objects, then you will need to set the DisplayMember and ValueMember properties to tell the ComboBox what property on the complex field to use for each of those, but since your item type is a string, you can just leave the DisplayMember and ValueMember fields blank.
|
|
|
Ben Hayat
|
|
Group: Forum Members
Posts: 374,
Visits: 1.2K
|
myCombo.DataSource = myBo.AllFieldsList; Never thought of that myself!
..ßen
|
|
|