+ Reply to Thread
Results 1 to 2 of 2

Thread: help with listview project

  1. #1
    Programming Professional Siten0308 will become famous soon enough Siten0308's Avatar
    Join Date
    Jun 2008
    Location
    California, USA
    Posts
    287

    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. #2
    Programming Professional Siten0308 will become famous soon enough Siten0308's Avatar
    Join Date
    Jun 2008
    Location
    California, USA
    Posts
    287

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Replies: 8
    Last Post: 05-30-2009, 11:56 AM
  2. Send image one project to another ?
    By nomanforu in forum C# Programming
    Replies: 0
    Last Post: 06-03-2008, 12:12 AM
  3. Contributing to a project
    By Jordan in forum Community Projects
    Replies: 7
    Last Post: 09-15-2006, 04:43 PM
  4. Community Project! - Recent project gone sour
    By Crane in forum C# Programming
    Replies: 5
    Last Post: 09-09-2006, 02:13 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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