)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display context choice popup for function in EditControl?

Platform: WinForms |
Control: EditControl |
Published Date: November 26, 2015 |
Last Revised Date: May 24, 2019

You can display the context choice popup for function, by defining required special character Config file which is loaded in EditControl.

 

The following code example demonstrates the same.

C#

//To populate context choice list
private void editControl1_ContextChoiceOpen(IContextChoiceController contextChoiceController)
{
    //To add context choice items.
    contextChoiceController.Items.Add("function1", "Dummy Function 1");
    contextChoiceController.Items.Add("function2", "Dummy Function 2");
    contextChoiceController.Items.Add("function3", "Dummy Function 3");
}
 
// Populate the context prompt list on popup
private void editControl1_ContextPromptOpen(object sender, Syncfusion.Windows.Forms.Edit.ContextPromptUpdateEventArgs e)
{
    switch (this.contextPromptLexem)
    {
        case "function1":
            e.List.Clear();
            e.AddPrompt("function1(string chatText, int senderID, int receiverID, int connectionID)", "Specify the chat text, the sender information, the receiver information and the connection ID");
            e.AddPrompt("function1(string chatText, int senderID, bool isBroadCast)", "Specify the chat text, the sender information, and if its a broadcast");
            break;
        case "function2":
            e.List.Clear();
            e.AddPrompt("function2()", "Create a new database");
            e.AddPrompt("function2(string dataBaseName)", "Create a new database with the specified name");
            break;
        case "function3":
            e.List.Clear();
            e.AddPrompt("function3()", "Create a new file");
            e.AddPrompt("function3(string fileName)", "Create a new file with the specified name");
            break;
    }
}

 

VB

'To populate context choice list
Private Sub editControl1_ContextChoiceOpen(ByVal contextChoiceController As IContextChoiceController) Handles editControl1.ContextChoiceOpen
 'To add context choice items.
 contextChoiceController.Items.Add("function1", "Dummy Function 1")
 contextChoiceController.Items.Add("function2", "Dummy Function 2")
 contextChoiceController.Items.Add("function3", "Dummy Function 3")
End Sub
 
' Populate the context prompt list on popup
Private Sub editControl1_ContextPromptOpen(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.ContextPromptUpdateEventArgs) Handles editControl1.ContextPromptOpen
 Select Case Me.contextPromptLexem
  Case "function1"
   e.List.Clear()
   e.AddPrompt("function1(string chatText, int senderID, int receiverID, int connectionID)", "Specify the chat text, the sender information, the receiver information and the connection ID")
   e.AddPrompt("function1(string chatText, int senderID, bool isBroadCast)", "Specify the chat text, the sender information, and if its a broadcast")
  Case "function2"
   e.List.Clear()
   e.AddPrompt("function2()", "Create a new database")
   e.AddPrompt("function2(string dataBaseName)", "Create a new database with the specified name")
  Case "function3"
   e.List.Clear()
   e.AddPrompt("function3()", "Create a new file")
   e.AddPrompt("function3(string fileName)", "Create a new file with the specified name")
 End Select
End Sub

 

XML

<!--To open the context prompt list after pressing the "(" in EditControl-->
  <lexem BeginBlock="(" EndBlock=")" Type="Operator" IsComplex="true" IsCollapsable="false" DropContextPrompt="true"
  CollapseName="(...)">
    <SubLexems>
      <lexem BeginBlock="\n" IsBeginRegex="true" />
    </SubLexems>
  </lexem>

 

Note:

The DropContextPrompt helps to show the dropdown list in EditControl.

 

 

Showing context prompt list

Figure 1: Context prompt list open when pressing the “(“ in EditControl.

Sample Links:

C#: EditControl_ContextPrompt_C#

VB: EditControl_ContextPrompt_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon