Closed Thread
Results 1 to 2 of 2

Thread: help with listview project

  1. #1
    Siten0308's Avatar
    Siten0308 is offline Programming Professional
    Join Date
    Jun 2008
    Location
    California, USA
    Posts
    302
    Rep Power
    16

    Question help with listview project

    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
    Code:
    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; }
            }
        }
    }
    mainform
    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 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)
            {
    
            }
        }
    }
    addform
    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();
            }
        }
    }
    Also, is there an easier way to do what i wanted to do?

    Thank you

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Siten0308's Avatar
    Siten0308 is offline Programming Professional
    Join Date
    Jun 2008
    Location
    California, USA
    Posts
    302
    Rep Power
    16

    Re: help with listview project

    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 : (

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Listview Help?????
    By jbnonn in forum C# Programming
    Replies: 3
    Last Post: 01-30-2011, 02:17 PM
  2. can fix it about listview
    By kiddies in forum Visual Basic Programming
    Replies: 2
    Last Post: 06-22-2010, 03:57 AM
  3. Help Using Listview
    By edge02 in forum Visual Basic Programming
    Replies: 2
    Last Post: 04-04-2010, 12:58 AM
  4. listview
    By Siten0308 in forum C# Programming
    Replies: 13
    Last Post: 12-12-2008, 09:14 AM
  5. ListView Help?
    By MXTECH in forum Visual Basic Programming
    Replies: 3
    Last Post: 11-17-2008, 12:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts