Accessing additional combobox columns...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
I've noticed that when I'm setting up a combobox to be filled using a BO that I only have two columns to work with. The value column and the display column. Obviously the value column contains the ID and the display column can be a single field or a combination field. IE {1} or {1}{2}. I'm assuming I cant add any more columns to the combo box to hold related information about the items in the combo box.



If I am able to add more columns could you please instruct how to do so and then tell me how to access the information in these extra columns.



OR How would I query the datatable in the BO that contains the extra data. Keep in mind I'm piggybacking on a BO. Which is to say I'm executing Stored procedures to return records to fill combo boxes with.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
No, the ComboBox is not sophisticated enough to store a tag like the ListView, so you can only store the information in either the display or the value column.  If necessary, you can call your stored procedure on a business object on the form (not the one dynamically created for the ComboBox) and use the CopyDataFrom method to copy data into the dynamicly created business object.  Then you would still have the business object on the form with all of the information necessary and you could Seek() to the record you need off the value in the ValueMember of the ComboBox.  Other than that, you would need some sort of complex drop down list with a custom control (like you would find in a 3rd party control suite).
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Ok. So now I'm going to use a DevExpress LookUpEdit. I'm assuming I can't do the piggyback thing with the lookupedit. Right? Is there another way or do I need to create a dataadapter and a dataset to fill the lookupedit?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
On a LookupEdit, you can set a business object as the DataSource.  Just remember to set the IsListSource property to True on the business object before you set it as the DataSource.  Then, yes, you will still be able to piggy back off of a business object.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
On the LookUpEdit I have set the datasource to the BO. I have set the DisplayMember and ValueMember to "hidden" fields (by hidden I mean columns from the Stored Procedure I'm going to use to fill the combobox). And I have the columns set the same.



I discovered that I have to call the method of the BO that executes the Stored Procedure before it will fill the LookUpEdit. When I do that, though, I havent filled the BO with its Primary data, so something funky happens to the grid I have bound to the BO. I see a number of blank rows that correlates to the number of items in the combobox I've filled using the piggyback method.



Of course once I fill the BO with its primary data the grid fixes itself and displays the BO data correctly. Just wondering if this is something you guys need to know about as far as a "bug".
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
It's not really a bug... the DevExpress control is building its column list at design-time, and the columns on the business object change at runtime, so you just need to call Me.LookUpEdit1.Properties.PopulateColumns() to rebuild the column list off the data that's actually in the business object (where "LookUpEdit1" is the name of your LookUpEdit control).  Then you should be good to go.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
After I said all that I ran into a problem. Tongue



When i filled the BO with its primary data it erased the data in my combobox.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, since the LookUpEdit is not one of our controls, it's not dynamically creating an instance of the business object on the back end, but actually using the business object that you're setting as the data source.  You'll need two different business objects on the form; one to be the source of the LookUpEdit, and one to be the primary business object you're working with.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
combobox.SelectedText isnt returning the value shown in the combo box after the selection. SelectedValue works ok though. Am I doing something wrong? I'm using the SF combobox which I assume inherits the windows one.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yeah, the .NET ComboBox has some issues with the SelectedText property not always returning what's selected.  Try the Text property as well.
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