Category / Section
How to get an object for the control present in an html element in WinForms HTMLUIControl?
1 min read
HTML elements
The GetControlByElement() method of the IInputHTML Interface returns the control present in the specified HTML element. If the HTML element does not contain any controls in it, it returns a null value by default.
C#
//Initializing the respective control's object private System.Windows.Forms.RadioButton htmlRadioButton; private void htmluiControl1_LoadFinished(object sender, System.EventArgs e) { //Collecting the html elements in a hashtable with their key as id Hashtable elements = this.htmluiControl1.Document.GetElementsByUserIdHash(); BaseElement radioElem = (BaseElement)elements["radio1"]; //Getting the Control from the html element and assigning it to the required object //The html element hereafter can be accessed with the help of the htmlRadioButton object htmlRadioButton = (RadioButton) this.htmluiControl1.Document.GetControlByElement(radioElem); }
VB
'Initializing the respective control's object Private htmlRadioButton As System.Windows.Forms.RadioButton Private Sub htmluiControl1_LoadFinished(ByVal sender As Object, ByVal e As System.EventArgs) 'Collecting the html elements in a hashtable with their key as id Dim elements As Hashtable = Me.htmluiControl1.Document.GetElementsByUserIdHash() Dim radioElem As BaseElement = CType(elements("radio1"), BaseElement) 'Getting the Control from the html element and assigning it to the required object 'The html element hereafter can be accessed with the help of the htmlRadioButton object htmlRadioButton = CType(Me.htmluiControl1.Document.GetControlByElement(radioElem), RadioButton) End Sub
Reference link: https://help.syncfusion.com/windowsforms/html-viewer/html-elements