Introduction
In this article I m going to discuss how to use DataGridView in window form and how to bind data from the XML file.
Here I am using the following XML file. This file contains the record of some books.
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<SrNumber>1</SrNumber>
<Title>ASP.NET 2.0</Title>
<Price>100 </Price>
<Author>Puru </Author>
<PublicationYear>1981 </PublicationYear>
</book>
<book>
<SrNumber>2</SrNumber>
<Title>Action Front </Title>
<Price>110 </Price>
<Author>Boyd Cable </Author>
<PublicationYear>1989 </PublicationYear>
</book>
<book>
<SrNumber>3</SrNumber>
<Title>Abraham Lincoln </Title>
<Price>180 </Price>
<Author>James Russell Lowell </Author>
<PublicationYear>1992 </PublicationYear>
</book>
<book>
<SrNumber>4</SrNumber>
<Title>Wisteria Lodge, The </Title>
<Price>150 </Price>
<Author>Arthur Conan Doyle </Author>
<PublicationYear>1983 </PublicationYear>
</book>
<book>
<SrNumber>5</SrNumber>
<Title>Club of Queer Trades, The </Title>
<Price>175 </Price>
<Author>Lowell </Author>
<PublicationYear>2002 </PublicationYear>
</book>
<book>
<SrNumber>6</SrNumber>
<Title>Anthem </Title>
<Price>250 </Price>
<Author>Ayn Rand </Author>
<PublicationYear>1971 </PublicationYear>
</book>
<book>
<SrNumber>7</SrNumber>
<Title>Common Sense </Title>
<Price>250 </Price>
<Author>Thomas Paine </Author>
<PublicationYear>1969 </PublicationYear>
</book>
<book>
<SrNumber>8</SrNumber>
<Title>Damaged Goods </Title>
<Price>300 </Price>
<Author>Upton Sinclair </Author>
<PublicationYear>2000 </PublicationYear>
</book>
<book>
<SrNumber>9</SrNumber>
<Title>Earth to the Moon </Title>
<Price>50 </Price>
<Author>Jules Verne </Author>
<PublicationYear>1992 </PublicationYear>
</book>
<book>
<SrNumber>10</SrNumber>
<Title>Hard Times </Title>
<Price>90 </Price>
<Author>Charles Dickens </Author>
<PublicationYear>2003 </PublicationYear>
</book>
</bookstore>
Now lets start how to use DataGridView. Simply open Visual Studio clik on File -> New -> Project and drag a DataGridView control from the toolbar on the form like as follows.

Figure 1. DataGridView control on Window Form.





Ayush GabaPosted Oct 29, 2012, 1:08 AM
I want to sorting implemented in window application .Can u Please help me.
nagham ghandourPosted Oct 26, 2011, 3:05 AM
hello there, why are you using buttons and code to sort data while it is an already existing feature by clicking the header
mostafa dayedPosted Mar 4, 2011, 3:18 AM
Thankyou
yogesh jadonPosted Jun 22, 2010, 6:49 AM
hi rathore... This is a good artical but I m working with only asp.net with c# web application so it will not helpful for me.