General Information
.NET Subscription
Desktop
Web
Controls and Extensions
Mainteinance Mode
Enterprise and Analytic Tools
Quality Assurance and Productivity
Frameworks and Libraries
General Information
.NET Subscription
Desktop
Web
Controls and Extensions
Mainteinance Mode
Enterprise and Analytic Tools
Quality Assurance and Productivity
Frameworks and Libraries
XRControl.HtmlItemCreated Event
Occurs when a new item used for a Web representation of the control is created.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v19.2.dll
Declaration
public virtual event HtmlEventHandler HtmlItemCreated
Public Overridable Event HtmlItemCreated As HtmlEventHandler
Event Data
The HtmlItemCreated event handler receives an argument of the HtmlEventArgs type. The following properties provide information specific to this event.
Property | Description |
---|---|
Brick | Gets a visual brick that represents the content of the currently processed item on a report page. |
ContentCell | Gets the content of the currently processed item. |
ScriptContainer | Gets an object that implements the IScriptContainer interface and is used for registering the scripts and styles in the current HTML document. |
Remarks
This event is used for creating a customized view of controls on a Web page.
Examples
Tip
Online Example: How to customize control content on export to HTML
The following example demonstrates how to use the XRControl.HtmlItemCreated event to customize the content of an XRLabel control, when a report is exported to HTML. In the event handler, create two custom HTML elements, which will display a check box and a hyperlink on a Web page, and add them to the control's content using the HtmlEventArgs.ContentCell property of the event parameter.
For this example to work correctly, do the following.
- Start Microsoft Visual Studio 2010, 2012, 2013, 2015 or 2017, and create a new Windows Forms Application or open an existing one.
- Add a new report (named XtraReport1) to the application.
Drop an XRLabel control onto a report and handle its HtmlItemCreated event as follows.
using DevExpress.XtraPrinting.HtmlExport; using DevExpress.XtraPrinting.HtmlExport.Controls; using DevExpress.XtraReports.UI; // ... private void xrLabel1_HtmlItemCreated(object sender, HtmlEventArgs e) { // Clear content of the currently processed item. e.ContentCell.Controls.Clear(); // Create a check box. DXHtmlGenericControl checkBox = new DXHtmlGenericControl(DXHtmlTextWriterTag.Input); checkBox1.Attributes["checked"] = "true"; checkBox1.Attributes["type"] = "CheckBox"; // Create a hyperlink. DXHtmlAnchor hypLink = new DXHtmlAnchor(); hypLink.InnerText = "XtraReports Web Page"; hypLink.HRef = "https://www.devexpress.com/Subscriptions/Reporting/"; // Add the created elements to the item's content. e.ContentCell.Controls.Add(checkBox); e.ContentCell.Controls.Add(hypLink); }
Imports DevExpress.XtraPrinting.HtmlExport Imports DevExpress.XtraPrinting.HtmlExport.Controls Imports DevExpress.XtraReports.UI ' ... Private Sub xrLabel1_HtmlItemCreated(sender As Object, e As HtmlEventArgs) ' Clear content of the currently processed item. e.ContentCell.Controls.Clear() ' Create a check box. Dim checkBox As New DXHtmlGenericControl(DXHtmlTextWriterTag.Input) checkBox1.Attributes("checked") = "true" checkBox1.Attributes("type") = "CheckBox" ' Create a hyperlink. Dim hypLink As New DXHtmlAnchor() hypLink.InnerText = "XtraReports Web Page" hypLink.HRef = "https://www.devexpress.com/Subscriptions/Reporting/" ' Add the created elements to the item's content. e.ContentCell.Controls.Add(checkBox) e.ContentCell.Controls.Add(hypLink) End Sub
Then, to export a report to HTML, you can use code similar to the following.
using System;
using System.Windows.Forms;
using System.Diagnostics;
// ...
private void ExportToHTML() {
XtraReport1 report = new XtraReport1();
report.ExportToHtml("Test.html");
StartProcess("Test.html");
}
public void StartProcess(string path) {
Process process = new Process();
try {
process.StartInfo.FileName = path;
process.Start();
process.WaitForInputIdle();
}
catch { }
}
Imports System
Imports System.Windows.Forms
Imports System.Diagnostics
' ...
Private Sub ExportToHTML()
Dim report As New XtraReport1()
report.ExportToHtml("Test.html")
StartProcess("Test.html")
End Sub
Public Sub StartProcess(ByVal path As String)
Dim process As New Process()
Try
process.StartInfo.FileName = path
process.Start()
process.WaitForInputIdle()
Catch
End Try
End Sub