?
Solved

Using Listview box in C# to display a rss feed

Posted on 2013-11-10
8
Medium Priority
?
562 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

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