Hello,
After further research and thanks to some posts you guys made, i was able to get very far, but now i have a problem, the problem is... the error message below:
inconsistant accessability: parameter type: predictionary.class1 is less accessible than method addtolistview... so i assume, ok maybe i should make class1 one a public, add public to class1 like so: public class class1, if i do that more ERRORS come!!! whats the deal?
the second error message is below:
cannot Convert Generic.KeyValuePair<int, class1> to picdictionary.class1, what am i doing wrong on that? i have the code below, class1, main form with the list view, and addform which you click the add button on main form and pops up addform with textboxes, when you click on submit, it goes back to main form, gets the info from the text boxes, and populates the listview.
class1
mainformCode:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace practicedictionary { class class1 { private int num; private static int num1; private string firstn; private string lastn; public class1() { num = num1; num1++; firstn = ""; lastn = ""; } public string FirstN { get { return firstn; } set { firstn = value; } } public string LastN { get { return lastn; } set { lastn = value; } } public int Num { get { return num; } set { num = value; } } } }
addformCode:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace practicedictionary { public partial class frmmain : Form { public frmmain() { InitializeComponent(); } Dictionary<int, class1> dictionaryvar = new Dictionary<int, class1>(); private void btnclose_Click(object sender, EventArgs e) { this.Close(); } private void btnadd_Click(object sender, EventArgs e) { frmadd formadding = new frmadd(); formadding.ShowDialog(); } public void addtolistview(class1 iv) { dictionaryvar.Add(iv.Num, iv); Populatelistview(); } public void Populatelistview() { listView1.Items.Clear(); foreach (class1 i in dictionaryvar) { string[] newitem = { i.Num.ToString(), i.FirstN, i.LastN }; ListViewItem lvi = new ListViewItem(); lvi.Tag = i; clmnfirstn.ListView.Items.Add(lvi); } } private void frmmain_Load(object sender, EventArgs e) { } } }
Also, is there an easier way to do what i wanted to do?Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace practicedictionary { public partial class frmadd : Form { public frmadd() { InitializeComponent(); } private void btnsubmit_Click(object sender, EventArgs e) { class1 variables = new class1(); variables.FirstN = txtbfirstn.Text; variables.LastN = txtblastn.Text; this.Close(); } } }
Thank you
Hello Everyone,
Well for some strange reason, i tried to make class1 as public: public class class1, and now the error message went away that says: inconsistant accessability: parameter type: predictionary.class1 is less accessible than method addtolistview,
now i just need help for the foreach problem, which is the second error message,
cannot Convert Generic.KeyValuePair<int, class1> to picdictionary.class1
Please help : (
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks