Example:-
I would like to display a table that has some styles.
In that case I may not replicate exactly using windows applications.
So, if we prepare a html content using required styles and can use that content to display required information.
Windows provides a component called “web browser”, we can just just drag and drop the component onto windows form.
Now I refer this web browser object as “objBrowser”, and use this object to display the html content that I prepare.
HTML content I am willing to display is a table with some style applied to it.
Content
<table cellpadding=’0’ cellspacing=’0’ border=’0’ align=’center’>
<tr style=’border: 1px solid #618773;’><td>Hi</td><td> Friends</td></tr>
<tr style=’border: 1px solid #618773;’><td colspan=’2’>Welcome to my blog</td></tr>
</table>
Windows form
Code file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Learnings
{
public partial class Browser : Form
{
public Browser()
{
InitializeComponent();
}
private void Browser_Load(object sender, EventArgs e)
{
string strContent = "<table cellpadding=’0’ cellspacing=’0’ border=’0’ align=’center’><tr style=’border: 1px solid #618773;’><td>Hi</td><td> Friends</td></tr><tr style=’border: 1px solid #618773;’><td colspan=’2’>Welcome to my blog</td></tr></table>";
objBrowser.DocumentText = strContent;
}
}
}
Output:-
No comments:
Post a Comment