private void lvBill_MouseUp(object sender, MouseEventArgs e) { ListViewItem ItemSelected = lvBill.GetItemAt(e.X, e.Y); ListViewHitTestInfo i = lvBill.HitTest(e.X, e.Y); Count = i.SubItem; Price = ItemSelected.SubItems[1]; Sum = ItemSelected.SubItems[3]; TxtEdit.Location = new Point(ItemSelected.SubItems[2].Bounds.X, ItemSelected.SubItems[2].Bounds.Y); TxtEdit.Visible = true; TxtEdit.BringToFront(); TxtEdit.Text = ItemSelected.SubItems[2].Text; TxtEdit.Select(); TxtEdit.SelectAll(); }
private void PositionsListView_MouseUp(object sender, MouseEventArgs e) { if (e.Button.ToString() != "Left") { return; } ListViewHitTestInfo i = PositionsListView.HitTest(e.X, e.Y); SelectedLSI = i.SubItem; if (SelectedLSI == null) { return; } int border = 0; switch (PositionsListView.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 + PositionsListView.Left + i.SubItem.Bounds.Left; int CellTop = PositionsListView.Top + i.SubItem.Bounds.Top; // First Column if (i.SubItem == i.Item.SubItems[0]) { CellWidth = PositionsListView.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 EnterEditMode(KeyEventArgs e) { if (TxtEdit.Visibility != Visibility.Visible) { TxtEdit.Visibility = Visibility.Visible; TxtOverview.Visibility = Visibility.Hidden; TxtEdit.Focus(); Keyboard.Focus(TxtEdit); TxtEdit.SelectionStart = TxtEdit.Text.Length; // If it is the default text, select it all in a bid to allow the user to delete it with one keypress... if (TxtEdit.Text == StringNodeContent.DEFAULT_NODE_CONTENT) { TxtEdit.SelectAll(); } } }