Esempio n. 1
0
        private void UrlsListView_MouseUp(object sender, MouseEventArgs e)
        {
            SelectedRowIndex    = -1;
            SelectedColumnIndex = -1;
            var info = UrlsListView.HitTest(e.X, e.Y);

            if (info.Item != null)
            {
                SelectedRowIndex    = info.Item.Index;
                SelectedColumnIndex = info.Item.SubItems.IndexOf(info.SubItem);

                if (e.Button == MouseButtons.Right)
                {
                    ListContextMenuStrip.Show(Cursor.Position);
                }

                if (e.Button == MouseButtons.Left)
                {
                    // Raise the DoubleClick event.
                    int now = Environment.TickCount;
                    if (now - _previousUrlsListViewClick <= SystemInformation.DoubleClickTime)
                    {
                        UrlsListViewMouseDoubleClick(sender, e);
                    }
                    _previousUrlsListViewClick = now;
                }
            }
        }
Esempio n. 2
0
        private void UrlsListViewMouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo hit = UrlsListView.HitTest(e.Location);

            Rectangle rowBounds   = hit.SubItem.Bounds;
            Rectangle labelBounds = hit.Item.GetBounds(ItemBoundsPortion.Label);
            int       leftMargin  = labelBounds.Left - 1;

            _urlsListViewCustomEdit.Bounds = new Rectangle(rowBounds.Left + leftMargin, rowBounds.Top, UrlsListView.Columns[hit.Item.SubItems.IndexOf(hit.SubItem)].Width - leftMargin - 1, rowBounds.Height - 2);
            _urlsListViewCustomEdit.Text   = hit.SubItem.Text;
            _urlsListViewCustomEdit.SelectAll();
            _urlsListViewCustomEdit.Visible = true;
            _urlsListViewCustomEdit.Focus();
        }