Solved

Using the datagrid (winforms) + binding to xml?

Posted on 2006-06-19
4
614 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 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

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…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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