Click here to Skip to main content
15,906,816 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to change MenuStrip default icon when child is maximized Pin
bcryner18-Dec-08 5:06
bcryner18-Dec-08 5:06 
QuestionAdd Table to XML file using Dataset... Pin
Greg Cetti17-Dec-08 10:11
Greg Cetti17-Dec-08 10:11 
Questioninsert space with pattern matching. Pin
Member 232448317-Dec-08 10:02
Member 232448317-Dec-08 10:02 
AnswerRe: insert space with pattern matching. Pin
User 665817-Dec-08 10:19
User 665817-Dec-08 10:19 
GeneralRe: insert space with pattern matching. Pin
Member 232448317-Dec-08 10:36
Member 232448317-Dec-08 10:36 
QuestionWinForms - Grid View bind to xml file Pin
duk3nukem17-Dec-08 9:55
duk3nukem17-Dec-08 9:55 
AnswerRe: WinForms - Grid View bind to xml file Pin
bcryner17-Dec-08 11:12
bcryner17-Dec-08 11:12 
GeneralRe: WinForms - Grid View bind to xml file [modified] Pin
duk3nukem18-Dec-08 5:17
duk3nukem18-Dec-08 5:17 
Thank you very much for your reply.
While i was reading your reply, i came aware of the Tables[] collection and assigning the Tables[0] was half of the solution for my problem.

i had in my code 2 problems:
1. Seems columns werent created properly.
Adding this line:
dataGridView1.AutoGenerateColumns = true;

Solved it. Wierd thing is i had already 2 coulmns with names "title" & "des".
2. As mentioned in begining, nothing was showing up on GridView, till i've pointed DataSource to be Tables[0].

Solution looks like this:
private void button1_Click(object sender, EventArgs e)
{
   string xmlPath = @"..\..\XMLFile1.xml";
 
   dataSet1.ReadXml(xmlPath);
   dataGridView1.AutoGenerateColumns = true;
   dataGridView1.DataSource = dataSet1.Tables[0];
}




EDIT:
I found why the columns i previously added wouldnt show up the values i wanted.
Previously neglected to set on the column the DataPropertyName to "title" & "des" as well.
I wrongly assumed that the "name" of field was enough.

With the DataPropertyName set properly, code looks like:
private void button1_Click(object sender, EventArgs e)
{
   string xmlPath = @"..\..\XMLFile1.xml";
 
   dataSet1.ReadXml(xmlPath);
   dataGridView1.DataSource = dataSet1.Tables[0];
}


the only problem was need to set source to table 0.

"Assumptions is the mother of all f***ups"

modified on Thursday, December 18, 2008 11:30 AM

AnswerRe: WinForms - Grid View bind to xml file Pin
AnthoJoh18-Dec-08 4:48
AnthoJoh18-Dec-08 4:48 
GeneralRe: WinForms - Grid View bind to xml file [modified] Pin
duk3nukem18-Dec-08 5:24
duk3nukem18-Dec-08 5:24 
QuestionC# and .ZIP files Pin
amityo17-Dec-08 9:01
amityo17-Dec-08 9:01 
AnswerRe: C# and .ZIP files Pin
Christian Graus17-Dec-08 9:14
protectorChristian Graus17-Dec-08 9:14 
GeneralRe: C# and .ZIP files Pin
led mike17-Dec-08 9:22
led mike17-Dec-08 9:22 
AnswerRe: C# and .ZIP files Pin
Lev Danielyan18-Dec-08 0:38
Lev Danielyan18-Dec-08 0:38 
Questionhow to put the annotation to the place where mouse click for chart control Pin
Seraph_summer17-Dec-08 8:35
Seraph_summer17-Dec-08 8:35 
QuestionVisual Studio Team System Novice - How to start Pin
Nadia Monalisa17-Dec-08 8:34
Nadia Monalisa17-Dec-08 8:34 
AnswerRe: Visual Studio Team System Novice - How to start Pin
Christian Graus17-Dec-08 9:03
protectorChristian Graus17-Dec-08 9:03 
GeneralRe: Visual Studio Team System Novice - How to start Pin
Nadia Monalisa17-Dec-08 9:18
Nadia Monalisa17-Dec-08 9:18 
GeneralRe: Visual Studio Team System Novice - How to start Pin
Christian Graus17-Dec-08 9:52
protectorChristian Graus17-Dec-08 9:52 
QuestionTabControl events Pin
nlowdon17-Dec-08 8:12
nlowdon17-Dec-08 8:12 
AnswerRe: TabControl events Pin
#realJSOP17-Dec-08 8:23
professional#realJSOP17-Dec-08 8:23 
GeneralRe: TabControl events Pin
Luc Pattyn17-Dec-08 8:52
sitebuilderLuc Pattyn17-Dec-08 8:52 
GeneralRe: TabControl events Pin
nlowdon17-Dec-08 10:15
nlowdon17-Dec-08 10:15 
GeneralRe: TabControl events Pin
Luc Pattyn17-Dec-08 10:22
sitebuilderLuc Pattyn17-Dec-08 10:22 
GeneralRe: TabControl events Pin
nlowdon17-Dec-08 10:41
nlowdon17-Dec-08 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.