Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

ResultSetTextBox

0.00/5 (No votes)
31 May 2005 1  
Displays data contained in a DataSet into a RichEdit control.

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 DataTables 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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here