Introduction
Hello pals. This is really a short article so I am gonna go straight to the point. I came with the idea of developing this simple control because I was developing an application where in one form I had to display data contained in a DataSet
and didn't want to use a DataGrid
for this purpose. After I did it, I thought it was sort of cool so I decided to share it with you. This is a picture of the control during runtime:
Displaying the data is very simple. Here's the snippet of code I use to load the DataSet
. Currently, the control displays all DataTable
s in the DataSet
.
private void btnOpen_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("C:\\myFile.xml");
this.resultSetTextBox1.DataSource = ds;
this.resultSetTextBox1.DataBind();
}
The only change to this article is that, at first when I posted it, it did not include the source code. So here it is.
The control has several properties as:
bool ShowTableNames
: which decides whether to include the table names in the result sets.
int DefaultColumnWidth
: is the width for the columns and DataRow[Column]
. If the width of one of the DataRow[Column]
's is wider than DefaultColumnWidth
, this DataRow[Column]
length is cut to DefaultColumnWidth - 2
. This is simply to avoid the overlapping of one DataRow[Column]
to the other DataRow[Column]
.
Well, that's all there's to it. I expect that you like it. All comments are welcome.