Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have made an extended provider control. So far, so good. It works like I want to.

In the properties of the provider I can select "Country" and "Food".

Each control in the form gets a new property attribute: "Select sub".

The idea is that when I have selected "Country" in the provider, I should select countries from the dropdown in "select sub" (property of a control on form).
When I select "Food" in the provider, the items in the dropdown of the control should be types of food (Apple, Bread, you name it).

This is in plain English what my application should do:

1. Add the own made provider to the form.
2. Add a button to the form
3. At the properties of the provider, select "Country"
4. Open the properties of the button. Search for the property "Select sub". Select a country here.
5. Open the properties of the provider again. Select "Food"
6. In the properties of the button, search for "Select sub". Select a food-type here.

NOTE: This is all in design-time!

And now my question:
How can I change the value of the dropdown in the control according to the value selected in the provider?

Hope my question is clear and that someone can help me.

Thanks in advance.
Posted
Comments
Ankur\m/ 21-Oct-10 2:46am    
Use 'Add Comment' below a user's answer to discuss with him. Adding an answer doesn't notify him about your question.
William Winner 21-Oct-10 11:07am    
I fixed the link and added a bit to the answer...

1 solution

I don't think it's possible. The only way I know of to specify a list of items for a provided property is to use an enum. But there's no way to tell the control to use a different type of enum based on a certain selection.

I wrote an article a while back about an ExtenderProvider that I created to add spell-checking to textboxes. I did have custom drop-down lists that were populated dynamically, but they were on actual properties, not provided properties. (in my code, see Property Language )

I don't see any way that you can do that. In fact, I would even question why you would want to do that. Provided properties do not give you a lot of control of how they are shown or what they can contain.

But, if you're curious about what I did, you can get my source code and there's a brief explanation on how to do dynamic design-time selection. (NHunspellTextBoxExtender[^])

[Fixed the link...seems to keep removing the x from aspx]

The only suggestion that I would have would be to have two provided properties. One for Country and one for food.

When the user selects Country in the property for the extender, then it uses the selection in the Country provided property and ignores anything that was selected in the Food provided property.

The issue, like I said, is that to provide a list of options to the designer, you would have to create an enum and then set that property type as that enum. But, you can't change the type to a different enum dynamically, which is why, AFAIK, you can't do what you're wanting to do.
 
Share this answer
 
v3
Comments
Ankur\m/ 21-Oct-10 2:45am    
[moved from answer]
Kenji Elzerman wrote:
Hi William,

First of all: Thanks for the reply.

I was just curious about the prodiver. I was trying this:

(more info about the steps the user should take, as shown in my first post)
1. Add the own made provider to the form.
2. Add a button to the form
3. At the properties of the provider, select "Country"
4. Open the properties of the button. Search for the property "Select sub". Select a country here.
5. Run the applicatie. The caption of the button is the country you have chosen. Exit the application. 6. Open the properties of the provider again. Select "Food"
7. In the properties of the button, search for "Select sub". Select a food-type here.
8. Run the application again. Now the caption of the button the food you have selected.
The main idea is that I don't have to set the caption with code. Okay, caption is a bad example (caption can be set in the property-window), but a nice way to check if my idea works.

If it is not possible at all, I will drop it and find a different way. But that's developing, right? Test, try, try again but different. Smile

Your link does not work. I get an Page not found.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900