Solved

Using the datagrid (winforms) + binding to xml?

Posted on 2006-06-19
4
592 Views
Last Modified: 2008-01-09
Hi there,

Can anybody tell me if its possible to have ROW HEADERS rather than column headers, i can't seem to find it. I need to add these manually

Also is it possible to bind it to an XML file i have?

The xml file contains other data also.... so i would need to exclude that...

The information that i want to display doesn't really need to binded to a database ... so is it possible to add to the grid in code?

Any help or information would be really appreciated

Thanks in advance

Ian
0
Comment
Question by:ianinspain
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 250 total points
ID: 16933527
Hi ianinspain,

You need to create an empty dataset, then use the .LoadXML("Path\filename.xml") method to load the xml data into the dataset, this can then be bound to the grid to display. You can modify the dataset as much as you like in order to remove some of the information, it will of course not be reflected in the file unless you use .WriteXML() to write it back.

Tim Cottee
0
 

Author Comment

by:ianinspain
ID: 16933614
wow ... thanks thats great! I will take a look now..

Is it also possible to add ROW headers .. like descriptions i.e.


Total        89
Pending    20
Awaiting   11

etd.. i.e the row headers are descriptions for each row...

Do i have to force this information into the xml file to get it to print it .... ??
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 16933684
ianinspain,

Yes you would, there is no RowHeaders collection like the ColumnHeaders so you would need to manipulate the data to do this in some fashion I am afraid.

Tim
0
 
LVL 28

Assisted Solution

by:iboutchkine
iboutchkine earned 250 total points
ID: 16934080
that will work for datagridview. I did not try for the datagrid

Private Sub dataGridView1_RowPostPaint(ByVal sender As Object, _
  ByVal e As DataGridViewRowPostPaintEventArgs) _
    Handles dataGridView1.RowPostPaint

  ' Paint the row number on the row header.
  ' The using statement automatically disposes the brush.

Using b As SolidBrush = _
    New SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor)

  e.Graphics.DrawString( _
    e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture), _
    e.CellStyle.Font, _
    b, _
    e.RowBounds.Location.X + 20, _
    e.RowBounds.Location.Y + 4)

End Using

End Sub
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now