Articles in this section
Category / Section

How to display context choice popup for function in EditControl?

2 mins read

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied