我试图通过单击ListView中的一行来打开新表单,并将特定行中列出的NoteId传递给新表单,有人可以帮忙吗?
对不起,如果这是一个愚蠢的问题,但是我从上个月才开始编程,而我的研究证明是徒劳的:(
private void populatingMainList()
{
List<Note> getAllNotes = GetAllNotes();
lstMain.Items.Clear();
for (int i = 0; i < getAllNotes.Count; i++)
{
lstMain.FullRowSelect = true;
string _note;
ListViewItem lvi = new ListViewItem(_note = getAllNotes[i].NoteComplete.ToString());
if (_note == "True")
{
lvi.Text = "";
lvi.Checked = true;
}
else
{
lvi.Text = "";
lvi.Checked = false;
}
lvi.SubItems.Add(getAllNotes[i].NoteTitle);
lvi.SubItems.Add(getAllNotes[i].NoteDot.ToString("dd-MM-yyyy"));
lvi.SubItems.Add(getAllNotes[i].NoteNote);
lvi.SubItems.Add(getAllNotes[i].NoteId.ToString());
lstMain.Items.Add(lvi);
}
}
private void lstMain_SelectedIndexChanged_1(object sender, EventArgs e)
{
//I believe that some sort of code that retrieve NoteId from the specific Row must be added here.
if (_list == true)
{
frmSticky StickyForm = new frmSticky(_currentUser, _noteid);
}
}
答案 0 :(得分:1)
private void lstMain_SelectedIndexChanged_1(object sender, EventArgs e)
{
var lst = sender as ListView;
_noteid = lst.SelectedItems[0].SubItems[3];
if (_list == true)
{
frmSticky StickyForm = new frmSticky(_currentUser, _noteid);
}
}
答案 1 :(得分:0)