Category / Section
How to load intellisense function from XML in WinForms SyntaxEditor (EditControl)?
1 min read
Load intellisense function
In EditControl, you can achieve the intellisense functionality as achieved 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
Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/intellisense#populate-intellisense-pop-up