Hey guys I got quite a strange problem:
I created a form in #Develop that looks like so:
As you can see, there is a listView there. My goal is to load up contents from a file and display them into that listview. I do that, no errors or messages and then create a new listview with all of the data inside of it, but when I replace it, nothing happens. This is the form after it has loaded up and created the new listView:
Here is the code for the manage window:
the ManageLoad function is being called upon startup and I have tested it and it does execute that function when the form is opened. The getFeedList function is as follows:
I'm thinking that even if I failed to load the data, the column headers would still show up. Any ideas of why it's not changing? I'm not getting any message boxes popping up either so it's not hitting any snags in the function.
I created a form in #Develop that looks like so:
As you can see, there is a listView there. My goal is to load up contents from a file and display them into that listview. I do that, no errors or messages and then create a new listview with all of the data inside of it, but when I replace it, nothing happens. This is the form after it has loaded up and created the new listView:
Here is the code for the manage window:
C#:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FeedMe
{
public partial class Manage : Form
{
public Manage()
{
InitializeComponent();
}
void ManageLoad(object sender, EventArgs e)
{
this.listView = new Utility().getFeedList();
this.Refresh();
this.Update();
}
void Button3Click(object sender, EventArgs e)
{
// save, then
this.Close();
}
}
}
the ManageLoad function is being called upon startup and I have tested it and it does execute that function when the form is opened. The getFeedList function is as follows:
C#:
StreamReader sr = new StreamReader(Stream.Null);
ListView listView = new ListView();
int feedCount = 0;
string[] feedNames = new string[feedCount+1];
string[] feedLinks = new string[feedCount+1];
string[] feedImgs = new string[feedCount+1];
try{
sr = new StreamReader(".\\resources\\feeds.cfg");
} catch (Exception e) {
MessageBox.Show("Could not open feeds.cfg. Please make sure that it is available. You can create a new one using Feeds > Manage");
new Logger().write("Could not open feeds.cfg: "+e.ToString());
return new ListView();
}
string line = string.Empty;
while((line = sr.ReadLine()) != null)
{
try{
string newFeedName = line.Substring(0, line.IndexOf(' '));
line = line.Substring(line.IndexOf(' ')+1);
string newFeedLink = line.Substring(0, line.IndexOf(' '));
line = line.Substring(line.IndexOf(' ')+1);
string newFeedImg = line;
try{
feedNames[feedCount] = newFeedName;
feedLinks[feedCount] = newFeedLink;
feedImgs[feedCount] = newFeedImg;
feedCount++;
string[] new_feedNames = new string[feedCount+1];
string[] new_feedLinks = new string[feedCount+1];
string[] new_feedImgs = new string[feedCount+1];
feedNames = new_feedNames;
feedLinks = new_feedLinks;
feedImgs = new_feedImgs;
} catch (Exception e) {
new Logger().write("Exception while adding to feeds: "+e.ToString());
}
} catch (Exception e) {
MessageBox.Show("Corrupt line in feed list. Please create a new one using Feeds > Manage");
new Logger().write("Error with line '"+line+"':"+e.ToString());
}
}
ColumnHeader feedNameHeader = new ColumnHeader();
ColumnHeader feedLinkHeader = new ColumnHeader();
ColumnHeader feedImgHeader = new ColumnHeader();
feedNameHeader.Text = "Name";
feedNameHeader.Width = 150;
feedLinkHeader.Text = "URL";
feedLinkHeader.Width = 300;
feedImgHeader.Text = "Image";
feedImgHeader.Width = 100;
listView.Columns.Add(feedNameHeader);
listView.Columns.Add(feedLinkHeader);
listView.Columns.Add(feedImgHeader);
for(int c = 0; c < feedCount; c++)
{
ListViewItem item = new ListViewItem(feedNames[c]);
item.SubItems.Add(feedLinks[c]);
item.SubItems.Add(feedImgs[c]);
listView.Items.Add(item);
}
return listView;
I'm thinking that even if I failed to load the data, the column headers would still show up. Any ideas of why it's not changing? I'm not getting any message boxes popping up either so it's not hitting any snags in the function.