Я не могу заставить мою функцию работать, чтобы скопировать мой список из предыдущей формы.
Код Form1:
private void customerInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Customers.SelectedItems.Count != 0)
{
var myformmessagedialog = new MessageBoxForm
{
name = Customers.SelectedItems[0].SubItems[0].Text,
address = Customers.SelectedItems[0].SubItems[3].Text,
telephone = Customers.SelectedItems[0].SubItems[4].Text,
};
myformmessagedialog.LoadListView(Customers.Items);
myformmessagedialog.ShowDialog();
}
}
Код Form2 (Messageboxform):
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 ClaudsPizzeria
{
public partial class MessageBoxForm : Form
{
public MessageBoxForm()
{
InitializeComponent();
}
public string name;
public string address;
public string telephone;
public void LoadListView(System.Windows.Forms.ListView.ListViewItemCollection items)
{
orderListView.Clear();
orderListView.AddRange(items);
}
private void MessageBoxForm_Load(object sender, EventArgs e)
{
lblName.Text = name;
lbladdress.Text = address;
lbltelephone.Text = telephone;
}
}
}
ОШИБКА I GET:
Error 1 'System.Windows.Forms.ListView' does not contain a definition for ' AddRange' and no extension method 'AddRange' accepting a first argument of type 'System.Windows.Forms.ListView' could be found (are you missing a using directive or an assembly reference?) C:\Users\Claudiu\Documents\Visual Studio 2010\Projects\ClaudsPizzeria\ClaudsPizzeria\MessageBoxForm.cs 27 27 ClaudsPizzeria
Все, что я хочусделать, это скопировать мой список из моей основной формы в форму сообщения, и я получаю это.Я новичок в C #, так что извините, если я задаю глупые вопросы.