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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I accomplish multiple levels of context choice list implementation in the EditControl?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

Multiple levels of context choice list can be implemented by handling the ContextChoiceBeforeOpen and ContextChoiceOpen event.

C#

private void editControl1_ContextChoiceBeforeOpen(object sender, System.ComponentModel.CancelEventArgs e)

{


ILexem lex;


lex = this.editControl1.ContextChoiceController.LexemBeforeDropper as ILexem;


if ((lex.Text == "this") || (lex.Text == "me"))


firstLevel = true;


else if (ContextChoiceListPresenceCheck(contextChoiceListLevelOne, lex.Text) == true)


secondLevel = true;


else


e.Cancel = true;

}

 

private void editControl1_ContextChoiceOpen(Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController controller)

{


if (firstLevel == true)


{


controller.Items.Clear();


for (int i=0; i<contextChoiceListLevelOne.Length; i++)


{


controller.Items.Add(contextChoiceListLevelOne[i], "This is a" + contextChoiceListLevelOne[i], this.editControl1.ContextChoiceController.Images[i]);


}


}


else if (secondLevel == true)


{


controller.Items.Clear();


for (int i=0; i<contextChoiceListLevelOne.Length; i++)


{


controller.Items.Add(contextChoiceListLevelTwo[i], "This is a" + contextChoiceListLevelTwo[i], this.editControl1.ContextChoiceController.Images[i]);


}


}


firstLevel = false;


secondLevel = false;

}

 

VB

Private Sub editControl1_ContextChoiceBeforeOpen(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles editControl1.ContextChoiceBeforeOpen

Dim lex As ILexem

lex = CType(IIf(TypeOf Me.editControl1.ContextChoiceController.LexemBeforeDropper Is ILexem, Me.editControl1.ContextChoiceController.LexemBeforeDropper, Nothing), ILexem)


If (lex.Text = "this") OrElse (lex.Text = "me") Then


firstLevel = True


Else If ContextChoiceListPresenceCheck(contextChoiceListLevelOne, lex.Text) = True Then


secondLevel = True


Else


e.Cancel = True


End If

End Sub


Private Sub editControl1_ContextChoiceOpen(ByVal controller As Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController) Handles editControl1.ContextChoiceOpen


If firstLevel = True Then


controller.Items.Clear()


Dim i As Integer=0


Do While i < contextChoiceListLevelOne.Length


controller.Items.Add(contextChoiceListLevelOne(i), "This is a" & contextChoiceListLevelOne(i), Me.editControl1.ContextChoiceController.Images(i))


i += 1


Loop


ElseIf secondLevel = True Then


controller.Items.Clear()


Dim i As Integer=0


Do While i < contextChoiceListLevelOne.Length


controller.Items.Add(contextChoiceListLevelTwo(i), "This is a" & contextChoiceListLevelTwo(i), Me.editControl1.ContextChoiceController.Images(i))


i += 1


Loop


End If


firstLevel = False


secondLevel = False

End Sub

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