Solved

Using Listview box in C# to display a rss feed

Posted on 2013-11-10
8
538 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 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