comboBox user control

Posted by Freddy Boisseau on 17-Oct-2008 15:51

I am trying to create an user control that handles a ultraComboBox and I have 2 questions.

One is about the ultraCombBox. In the ultraComboBox I have two fields in the control not the code. Where is the property that I change to make it work that way?

I am also build the ultraComboBox in an user control with the necessary binding source. My question is when I place this in the screen how do I get my Primary binding source to interact with the binding source in the control? What I want is two things, one when I switch records, I want the control to show the entry associated the current record. I also want the value I selected using the control to update the current record when I assign the Primary binding source.

Can anyone help me with these two issues?

Thank you.

Freddy

All Replies

Posted by Admin on 19-Oct-2008 03:47

Regarding your first question:

You design the "grid part" (so when the combo is opened) of the UltraCombo using the Wizard/Designer. You remove unwanted fields by hiding them. The grid shows records from the DataSource (binding source) of the UltraCombo.

The colunm are defined using the ValueMember and DisplayMember property of the UltraCombo.

Tomorrow in the WebEx I'll be demoing a sample with a SalesRep ultraCombo where the ValueMember is the SalesRep column and the DisplayMember is the RepName column.

Now you usually want to connect the "Value" of the UltraCombo to the SalesRep column of a customer binding source.

This is done by setting the (DataBindings) Value property to the SalesRep column (sorry, member in OO language) of the customer binding source. It might be displayed as: bsCustomer - SalesRep

In your user control I guess the binding of the salesrep would be fixed in the user control - so in my sample it would be a SalesRepComboBox control. So you need to pass the external binding source (the bsCustomer) and the column name. You could to that using two properties or a single method.

You'll need to add the following line of code somewhere (after the properties are set or in the method call):

THIS-OBJECT:ultraCombo1:DataBindings:Add(NEW System.Windows.Forms.Binding("Value", THIS-OBJECT:bsCustomer, "SalesRep", TRUE)).

This defines the binding for the Value property to the SalesRep column of the bsCustomer.

One thing you might consider should be, that for a single input control, inheritance might make your life easier when using it. Consider the requirement to have Leave/Entry/Keyboard etc. events and combobox specific events on the combo you'd like to react on in a Form. A user control only offers the events of a user control (System.Windows.Forms.UserControl). We can't extend them in 10.2A with our own events (or passing over combo box specific events). You'll also need to re-implement any property you'd might want to change in an individual form (like the DropDownWidth or the DataBindings properties).

Basically you need to decide if the encapsulation of a single combo box control in a user control is a blessing or a curse. Inheritance does not encapsulate the control. It adds default functionality (like an internal salesrep binding source).

Posted by Freddy Boisseau on 20-Oct-2008 10:47

Mike,

I was not able to connect to the webex, because of the bad link. I did not find the correct link here on the forum until after the webex was done. The ultraComboBox was not the only control I was putting in the user control. I was also putting in the bindingSource that filled the combo box with the valid record values. Is it possible to get your demo code to review?

Thank you

Freddy

Posted by Freddy Boisseau on 20-Oct-2008 14:19

I am having a real problem with this. I can not seem to figure out what properties I need to set to what to get the control to work for me. I have 3 values that I need to map.

1) the field value in the record table

2) the key field in the dataset that fills the combo box

3) the value that I want to have displayed

So what happens is the value in the customer.slsrep field is 'RIC'. That value is lookup in the dataset loaded in the combo box and the name 'Richard' is displayed.

Can someone tell me what properties I set to what values to get this to work?

Posted by Admin on 20-Oct-2008 14:26

Hi,

- set DataSource to a Progress.Data.BindingSource object connected to a SalesRep query or ProDataset.

- set ValueMember to "slsrep"

- set DisplayMember to "name"

- set (DataBindings) Value to slsrep in custom binding source

There's no need to prefix the member names with a table for the top level table in a dataset.

Attached is the sample from the WebEx.

Im also setting the SynchronizeWithCurrencyManager = True to make sure, the ultraCombo updates the Position of the salesrep binding source.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/SampleForm.cls:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/SampleForm.resx:550:0]

Mike

Posted by Freddy Boisseau on 20-Oct-2008 15:24

Mike,

Thank you for the help. I actually figured it out about the same time you posted your response.

I do not know how much control Progress has over the way the properties appear in the property viewer, but it would be helpful if the important normal values appeared in one section together. It just seems that I have to jump around the property view to find the properties I need for the simple things. For example the value field is at the top of the list, the datasource for the combo box is further down, the displaymember is a few rows down from there, and the valuemember is at the bottom.

Thank you again for the help.

Freddy

Posted by Admin on 20-Oct-2008 23:57

Mike,

Thank you for the help. I actually figured it out

about the same time you posted your response.

Great!

I do not know how much control Progress has over the

way the properties appear in the property viewer, but

it would be helpful if the important normal values

appeared in one section together.

That's the point. The property grid is a standard Microsoft Control. We can use it ourselves in apps as well (System.Windows.Forms.PropertyGrid). It uses meta-information or annotations stored in the assembly.

These annotations define:

- If a property appears in the property grid or not (runtime only properties are not shown in the property grid).

- The mini-description shown in the bottom of the property grid

- The type of editor: plain text (type-safe), a combo-box, a drop-down dialog like with Anchor, ...

- The property category

The property grid can display the properties by alphabet or by category.

This all is defined by the control vendor. Progress is using it.

The only way Progress could change the layout of the property would be by

- convincing the control vendor to change this or

- developing a specialized version of the property grid for each control

The first might be hard to achieve because a large Control vendor might response: We have millions of developers using it that way and we can't change the control behaviour. Also, If Progress would succeed with Infragistics, how about Component One, Telerik and the rest of the pack?

The second you move us away from the Control vendors documentation and every referece we find on google...

By the way: If you sort the UltraCombo Properties by category (the first tiny button in the top), the ...member properties show in a "Data" category and the (Binding) properties show in a "Daten" property - that might be an issue with a standard German translation because it both means the same. But "Daten" and "Data" are very close to each other.

Posted by Thomas Mercer-Hursh on 21-Oct-2008 11:12

"Data" category and the (Binding) properties show in a "Daten" property

Data and DataBindings in English.

Posted by jmls on 21-Oct-2008 16:21

Data and DataBindings in English.

Which english would that be ? Proper, or colonial ?

Posted by Thomas Mercer-Hursh on 21-Oct-2008 18:31

Neither ... what it says on the screen. Are they different on yours?

Posted by jmls on 22-Oct-2008 16:36

Neither ... what it says on the screen. Are they

different on yours?

No. I was just being a smartass.

http://www.ahajokes.com/eng002.html

Posted by Thomas Mercer-Hursh on 22-Oct-2008 16:42

No. I was just being a smartass.

What a surprise!

Posted by Freddy Boisseau on 23-Oct-2008 14:10

I have build the user control and have gotten it working pretty much like I want it to. I do have one question. Progress has always had the rule 'abc' = 'ABC' and I know that normally .NET 'abc' <> 'ABC'. But I was wondering if there was a way to change the .NET behavior to match the Progress rule?

This thread is closed