Solved

Using Listview box in C# to display a rss feed

Posted on 2013-11-10
8
553 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
[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
  • 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
Industry Leaders: 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!

 

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

Industry Leaders: 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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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