?
Solved

Using the datagrid (winforms) + binding to xml?

Posted on 2006-06-19
4
Medium Priority
?
619 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 1000 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 1000 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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 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