Peter Kiers
asked on
Modify the row of a listview.
Dear Experts,
I have tried to explain my problem in writing, but then the text get
to long and complicated. So I thougt to show it in a picture:
1. When a user click on the toolbar-button.
2. A grey form appears with a not-visible textbox on it.
3. When the user enters text (in this case: "Peter Pan") in the textbox
4. And clicks on the close-button for closing the form.
5. The text "Peter Pan" is now displayed in a listview-column.
This al works great.
But when I double-click on the icon "Peter Pan" again. The form
appears again with the text "Peter Pan" displayed in the textox.
If I know add more text to "Peter Pan", like "Peter Pan is lazy" and
click on the close-button again. The modified text isn't written back
to the listview! How can I do that?
Who knows the answer and is willing to help me? I have added the
toolbar-button-event and the listview double-click-event in the
code-section.
Greetings,
Peter Kiers
I have tried to explain my problem in writing, but then the text get
to long and complicated. So I thougt to show it in a picture:
1. When a user click on the toolbar-button.
2. A grey form appears with a not-visible textbox on it.
3. When the user enters text (in this case: "Peter Pan") in the textbox
4. And clicks on the close-button for closing the form.
5. The text "Peter Pan" is now displayed in a listview-column.
This al works great.
But when I double-click on the icon "Peter Pan" again. The form
appears again with the text "Peter Pan" displayed in the textox.
If I know add more text to "Peter Pan", like "Peter Pan is lazy" and
click on the close-button again. The modified text isn't written back
to the listview! How can I do that?
Who knows the answer and is willing to help me? I have added the
toolbar-button-event and the listview double-click-event in the
code-section.
Greetings,
Peter Kiers
private void tbNewNote_Click(object sender, EventArgs e)
{
frmNote.textBox1.Clear();
frmNote.lblCreation.Text = (DateTime.Now.ToString());
if (frmNote.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ListViewItem myItem = new ListViewItem(frmNote.textBox1.Text, 0);
myItem = lvNotes.Items.Add(myItem);
myItem.SubItems.Add("SubItem1a");
myItem.SubItems.Add(frmNote.lblCreation.Text);
lvNotes.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.HeaderSize);
}
}
private void lvNotes_DoubleClick(object sender, EventArgs e)
{
frmNote.textBox1.Text = lvNotes.SelectedItems[0].Text;
frmNote.textBox1.SelectionStart = 0;
frmNote.lblCreation.Text = lvNotes.SelectedItems[0].SubItems[2].Text;
frmNote.ShowDialog();
}
Example1.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It works.
Peter
Peter
ASKER
It think this line is correct but at the wrong place:
lvNotes.SelectedItems[0].T
Peter