コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }