Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Listview box in C# to display a rss feed

Posted on 2013-11-10
8
Medium Priority
?
579 Views
Last Modified: 2013-11-17
HI all
I am trying to get a rss feed to display in a listview box in C#, i ave got it displaying the names with no issues but more some reason i cant get them in any of the other col my code and feed is attached tanks so much in advance

*****FEED*******
<channel>
<item>
<title>
Name of Main item
</title>
<link>http://Thisisthelink.com</link>
<pubDate>11 Nov 2013 02:34:07 +0000</pubDate>

</item>


    rss:

            titlescomboBox.Items.Clear();
            rssData = getRssData(ChannelTextBox.Text);
            for (int i = 0; i < rssData.GetLength(0); i++)
            {
                if (rssData[0, 0] != null)
                {
                    titlescomboBox.Items.Add(rssData[i, 0]);
                    listView1.Items.Add(rssData[i, 0] , 0);
                   listView1.Items.Add(rssData[i, 1], 2);

                }

                titlescomboBox.SelectedIndex = 0;

            }

            //******Adding  Pubdate ******

          //  for (int r = 0; r< rssData.GetLength(2); r++)
           // {
             //   if (rssData[0, 2] != null)
               // {
                 //   titlescomboBox.Items.Add(rssData[r, 0]);
                   // listView1.Items.Add(rssData[r, 0], 1);

//                }

  //              titlescomboBox.SelectedIndex = 0;

    //        }

        }

        private void titlescomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rssData[titlescomboBox.SelectedIndex, 1] != null)
                decriptiontextBox.Text = rssData[titlescomboBox.SelectedIndex, 1];
            if (rssData[titlescomboBox.SelectedIndex, 2] != null)
                linkLabel.Text = "Goto: " + rssData[titlescomboBox.SelectedIndex, 0];

    {
    }
        }

        private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (rssData[titlescomboBox.SelectedIndex, 2] != null)
                System.Diagnostics.Process.Start(rssData[titlescomboBox.SelectedIndex,2]);

Open in new window

0
Comment
Question by:awolarczuk
  • 5
  • 3
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39639038
I see where you are adding items, but I don't see where you are adding sub-items to items.  That is the only way that you can populate the other columns of a ListView.
0
 

Author Comment

by:awolarczuk
ID: 39639699
i am trying to do it here

 listView1.Items.Add(rssData[i, 1], 2);

i am sure it is some ting dumb what have i missed??
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39639811
Another possibility is that you need to have View property set to Detail.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:awolarczuk
ID: 39640155
HI TheLearnedOne thanks for your response, i have it in details already is my code ok ???
0
 

Author Comment

by:awolarczuk
ID: 39640299
ok so using this i kinda have it working





titlescomboBox.Items.Add(rssData[i, 0]);
                    ListViewItem lvi = new ListViewItem(rssData[i, 0]);
                
                    lvi.SubItems.Add(rssData[i, 2]);
                    lvi.SubItems.Add(rssData[i, 3]);
                    listView1.Items.Add(lvi);

Open in new window




i just cant get the <pubDate>11 Nov 2013 02:34:07 +0000</pubDate> to show i get index was outside te bounds of the array
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39640435
You need to add columns to the ListView, as shown here:

 // Set to details view.
        listView1.View = View.Details;
        // Add a column with width 20 and left alignment.
        listView1.Columns.Add("File type", 20, HorizontalAlignment.Left);

Open in new window

0
 

Accepted Solution

by:
awolarczuk earned 0 total points
ID: 39640526
hi all just letting oyu know i got it to work using

 var feeds = from feed in feedXML.Descendants("item")
                                select new
                                {

                                    Title = feed.Element("title"),
                                    Link = feed.Element("link"),
                                    Date = feed.Element("pubDate"),
                                    Description = feed.Element("description")
                                };
                 


                    foreach (var feed in feeds)
                    {
                        ListViewItem lvi = new ListViewItem(feed.Title.Value); //Adding Title
                        lvi.SubItems.Add(feed.Link.Value); //Adding Link 12/11/2013 arw
                        lvi.SubItems.Add(feed.Date.Value); //Adding Pub Date 12/11/2013 are
                        listView1.Items.Add(lvi);
                        Console.WriteLine("Title:{0}, Date{1}", feed.Title.Value, feed.Date.Value);
                    }

                }


            }

Open in new window


just wondering how i go with the point now
0
 

Author Closing Comment

by:awolarczuk
ID: 39654288
As i found the way to do it
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

926 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