Articles in this section

How to load intellisense function from XML in WinForms SyntaxEditor (EditControl)?

Load intellisense function


In EditControl, you can achieve the intellisense functionality, as seen in Visual Studio, by handling its ContextChoiceOpen event. The following code example illustrates the same.

C#

private void editControl1_ContextChoiceOpen(Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController controller)
{
   reader = new XmlTextReader(intellisensePath);
   while (reader.Read())
   {
      string itemname = "", tooltip = "", category = "";
      switch (reader.NodeType)
      {
         case (XmlNodeType.Element):
                 if (reader.Name == "Items")
                 {
                    if (reader.AttributeCount > 0)
                    {
                       while (reader.MoveToNextAttribute())
                       {
                          if (reader.Name == "Name")
                          {
                             itemname = reader.Value;
                          }
                          if (reader.Name == "Tooltip")
                          {
                             tooltip = reader.Value;
                          }
                          if (reader.Name == "Category")
                          {
                            category = reader.Value;
                          }
                          if (reader.Name == "Image")
                          {
                             if (category.ToLower() == "class" && isParentClass)
                                controller.Items.Add(itemname, tooltip,  this.editControl1.ContextChoiceController.Images[0]);
                             if (category.ToLower() == "method" && (isParentClass || isChildClass || isMethod))
                                controller.Items.Add(itemname, tooltip, this.editControl1.ContextChoiceController.Images[1]);
                             if (category.ToLower() == "cmethod" && (isMethod || isCMethod))
                                controller.Items.Add(itemname, tooltip, this.editControl1.ContextChoiceController.Images[1]);
                             if (category.ToLower() == "property" && (isParentClass || isChildClass))
                                controller.Items.Add(itemname, tooltip, this.editControl1.ContextChoiceController.Images[2]);
                          }
                     }
                 }
             }
             break;
        }
    }
}

VB

Private Sub GetFunctionNames(ByVal e As ContextPromptUpdateEventArgs)
    reader = New XmlTextReader(intellisensePath)
[function] = ""
    Dim i As Integer = 1
    Do While reader.Read()
    [function] = ""
    Select Case reader.NodeType
    Case (XmlNodeType.Element)
             If reader.Name = "Function" Then
                reader.MoveToFirstAttribute()
             If reader.Value = Me.contextPromptLexem Then
                Do While reader.MoveToNextAttribute()
                     If reader.Name = "overloads" & i Then
                        [function] = reader.Value
                     ElseIf reader.Name = "Description" & i Then
                             e.AddPrompt([function], reader.Value)
                             i += 1
                     End If
               End If
               Loop
          End If
       End If
    End Select
    Loop
End Sub

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Intellisense_from_XML1834281398885065153.zip

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/intellisense#populate-intellisense-pop-up

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