Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use a hidden textbox to edit all the listview items/subitems. The only problem is that the textbox needs to disappear as soon as any event takes place outside the textbox and the listview doesn't trigger the scroll event so if you scroll the listview the textbox will still be visible. To bypass this problem I created the Scroll event with this <a href="https://stackoverflow.com/questions/372034/how-do-i-listen-for-scrolling-in-a-listview">overrided listview.</a></p> <p>Here is my code, I constantly reuse it so it might be help for someone:</p> <pre><code>ListViewItem.ListViewSubItem SelectedLSI; private void listView2_MouseUp(object sender, MouseEventArgs e) { ListViewHitTestInfo i = listView2.HitTest(e.X, e.Y); SelectedLSI = i.SubItem; if (SelectedLSI == null) return; int border = 0; switch (listView2.BorderStyle) { case BorderStyle.FixedSingle: border = 1; break; case BorderStyle.Fixed3D: border = 2; break; } int CellWidth = SelectedLSI.Bounds.Width; int CellHeight = SelectedLSI.Bounds.Height; int CellLeft = border + listView2.Left + i.SubItem.Bounds.Left; int CellTop =listView2.Top + i.SubItem.Bounds.Top; // First Column if (i.SubItem == i.Item.SubItems[0]) CellWidth = listView2.Columns[0].Width; TxtEdit.Location = new Point(CellLeft, CellTop); TxtEdit.Size = new Size(CellWidth, CellHeight); TxtEdit.Visible = true; TxtEdit.BringToFront(); TxtEdit.Text = i.SubItem.Text; TxtEdit.Select(); TxtEdit.SelectAll(); } private void listView2_MouseDown(object sender, MouseEventArgs e) { HideTextEditor(); } private void listView2_Scroll(object sender, EventArgs e) { HideTextEditor(); } private void TxtEdit_Leave(object sender, EventArgs e) { HideTextEditor(); } private void TxtEdit_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) HideTextEditor(); } private void HideTextEditor() { TxtEdit.Visible = false; if (SelectedLSI != null) SelectedLSI.Text = TxtEdit.Text; SelectedLSI = null; TxtEdit.Text = ""; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload