We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I close ContextChoice programmatically?

How can I close ContextChoice programmatically?

11 Replies

AD Administrator Syncfusion Team November 23, 2006 04:54 PM UTC

Hi ok,

Our apologies for the delayed response. It is possible to close ContextChoice programmatically using the CloseContextChoice method. This method is included in the beta version of 4.4. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample




AD Administrator Syncfusion Team November 24, 2006 08:04 AM UTC

Excellent! But I use version 4.302.0.30


AD Administrator Syncfusion Team November 28, 2006 01:36 PM UTC

Hi ok,

Our apologies for the delayed response. It is possible to hide the ContextChoice using the FormSize property of ContextChoiceController. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample


DU David Union December 1, 2006 08:41 PM UTC

This doesn't actually work.
It doesn't close the ContextChoice, it hides it by making the size small. The problem is that it's still there. So if you for example hit a down arrow and enter, you *get the text* in the context prompt, which is going to be the oddest behavior a user ever sees in the editor.

Is there a way just to 'cancel' this context choice box, that is fire off a cancel or a closecontextchoice event or something like it?


>Hi ok,

Our apologies for the delayed response. It is possible to hide the ContextChoice using the FormSize property of ContextChoiceController. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample


AD Administrator Syncfusion Team December 6, 2006 07:44 PM UTC

Hi dunion,

Our apologies for the delayed response. It is possible to close ContextChoice in version 4.4 using the CloseContextChoice method. It is also possible to cancel the ContextChoice using the ContextChoiceBeforeOpen event. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample


AD Administrator Syncfusion Team January 20, 2007 08:04 PM UTC

I've been able to cancel the ContextChoiceBeforeOpen event successfully to prevent a context choice from dropping down but I don't always know upfront if I'll need to cancel it. Because of this, I need to be able to close (or cancel) the context choice dialog from inside of the ContextChoiceOpen event. I've tried calling the CloseContextChoice method you've mentioned but it doesn't seem to work inside of a ContextChoiceOpen even handler. Any suggestions?

thanks,
Travis


DU David Union January 30, 2007 05:30 PM UTC

In theory they have a fixed version that claims you can close this from the ContextChoiceBeforeOpen() handler, which I have but I haven't tried this feature yet, there are too many other issues I'm trying to deal with. My earlier (successful) work-around was to start a timer and exit, then catch the event in the timer and close the contextprompt in the timer-handler and then execute the remainder of the code I needed there.

>I've been able to cancel the ContextChoiceBeforeOpen event successfully to prevent a context choice from dropping down but I don't always know upfront if I'll need to cancel it. Because of this, I need to be able to close (or cancel) the context choice dialog from inside of the ContextChoiceOpen event. I've tried calling the CloseContextChoice method you've mentioned but it doesn't seem to work inside of a ContextChoiceOpen even handler. Any suggestions?

thanks,
Travis


AD Administrator Syncfusion Team January 31, 2007 03:07 PM UTC

private bool CloseContextChoice()
{
if (edCode.ContextChoiceController.IsVisible)
{
edCode.KeyBindingProcessor.ProcessKey(Keys.Escape);
return true;
}
return false;
}


PR Purusothaman R Syncfusion Team February 1, 2007 06:26 PM UTC

Hi Olga,

The KeyBindingProcessor.ProcessKey(Keys.Escape) does not work in the ContextChoiceOpen event, since the Context Choice is not displayed. It works only after the Context Choice is displayed.

You can use the FormSize of the ContextChoiceController to obtain the desired behavior.

this.editControl1.ContextChoiceController.FormSize=new Size(0,1)

I am attaching a sample here which demonstrates the same. If this is not you needed, kindly modify the sample to show what is your actual need.

ContextChoiceSample

Thanks,
Purusothaman.R


AD Administrator Syncfusion Team February 1, 2007 08:05 PM UTC

FYI I had previously tried the form-size method but the problem was that the context list still had focus and it was easy for items from that list to get 'dropped' onto the edit window in a way that would appear 'odd' to the user. Maybe clear the Items array first?

>Hi Olga,

The KeyBindingProcessor.ProcessKey(Keys.Escape) does not work in the ContextChoiceOpen event, since the Context Choice is not displayed. It works only after the Context Choice is displayed.

You can use the FormSize of the ContextChoiceController to obtain the desired behavior.

this.editControl1.ContextChoiceController.FormSize=new Size(0,1)

I am attaching a sample here which demonstrates the same. If this is not you needed, kindly modify the sample to show what is your actual need.

ContextChoiceSample

Thanks,
Purusothaman.R


PR Purusothaman R Syncfusion Team February 2, 2007 02:36 AM UTC

Hi David,

To overcome the issue mentioned by you, I have cleared the Items in the Context Choice.

I have a check box in the sample to decide whether to show the ContextChoice or not. A flag variable is used to detect the "Enter" key in the sample to get the default behavior of moving to the next line when Enter key is pressed.

Please look in to the sample.
ContextChoice.zip

Thanks,
Purusothaman.R

Loader.
Live Chat Icon For mobile
Up arrow icon