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 toggle the visibility of an HTML element in HTMLUI at runtime?

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

 

Each HTML element in the HTMLUI has an xVisible attribute by default that helps the user to toggle the visibility of a particular element. Since the xVisible is a bool property the value to be set is either true or false as string.

The following code snippet shows how an element's visibility is toggled on the execution of an event.

C#

[HTML]

Cell Toggle

Cell Toggle

C#

IHTMLElement image = Global.Document.GetElementByUserId("img");

image.Click += new EventHandler(image_Click);

IHTMLElement[] elem = this.htmluiControl1.Document.GetElementsByName("td");

public void image_Click(object sender, EventArgs e)

{

string visibleString = "";

htmluiControl1.BeginUpdate();

if(this.bDescriptionHidden == false)

visibleString = "false";

else

visibleString = "true";

this.bDescriptionHidden = !this.bDescriptionHidden;

foreach (IHTMLElement description in elem)

{

if(description.ID == "tdpopup")

description.Attributes["xVisible"].Value = visibleString;

}

htmluiControl1.EndUpdate();

this.htmluiControl1.Refresh();

}

VB

Private image As IHTMLElement = Global.Document.GetElementByUserId("img")

Private image.Click += New EventHandler(image_Click)

Private elem As IHTMLElement() = Me.htmluiControl1.Document.GetElementsByName("td")

Public Sub image_Click(ByVal sender As Object, ByVal e As EventArgs)

Dim visibleString As String = ""

htmluiControl1.BeginUpdate()

If Me.bDescriptionHidden = False Then

visibleString = "false"

Else

visibleString = "true"

End If

Me.bDescriptionHidden = Not Me.bDescriptionHidden

For Each description As IHTMLElement In elem

If description.ID = "tdpopup" Then

description.Attributes("xVisible").Value = visibleString

End If

Next description

htmluiControl1.EndUpdate()

Me.htmluiControl1.Refresh()

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