|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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; }
}
}
}
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)
{
}
}
}
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 : ( |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FreeOrion (a non commercial, community game project, under development) | MikkoM | Video Game Talk | 8 | 05-30-2009 11:56 AM |
| Send image one project to another ? | nomanforu | C# Programming | 0 | 06-03-2008 12:12 AM |
| Contributing to a project | Jordan | Community Projects | 7 | 09-15-2006 04:43 PM |
| Community Project! - Recent project gone sour | Crane | C# Programming | 5 | 09-09-2006 02:13 PM |
Algorithms and Data Structures
Programming Language Popularity
Code Collaboration
Podnet IRC Network
AmpHosted
Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%