Solved

Using the datagrid (winforms) + binding to xml?

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio hangs on running project 6 85
Reactjs with .NET 3 127
ModalPopup  question 22 58
Installing .NET 3.5 on Windows Server 2012 1 94
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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