Click here to Skip to main content
15,893,337 members
Articles / Programming Languages / C#
Article

ResultSetTextBox

Rate me:
Please Sign up or sign in to vote.
1.90/5 (11 votes)
31 May 20051 min read 28.5K   557   12   2
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:

Image 1

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.

C#
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


Written By
Web Developer
Spain Spain
I have been programming for a few years now, like since 1996. Currently working as freelance.

C#.NET MCP. Works with tools such as Delphi, C#.NET, VB.NET, ASP.NET, ADO.NET, XML, java, j2me, Oracle, mySQL, and Sql Server, etc, etc. Open to everything.

Comments and Discussions

 
GeneralSource code Pin
Smitha Nishant23-May-05 23:01
protectorSmitha Nishant23-May-05 23:01 
GeneralRe: Source code Pin
Alexander German31-May-05 3:09
Alexander German31-May-05 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.