Solved

Using Listview box in C# to display a rss feed

Posted on 2013-11-10
8
532 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
 

Author Comment

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

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now