GetItemAt() public method

public GetItemAt ( int x, int y ) : System.Windows.Forms.ListViewItem
x int
y int
return System.Windows.Forms.ListViewItem
		private void lstvwPermissoes_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left)
			{
				int colIndex = GetColumnIndex(e.X, e.Y);
				if (colIndex > 0)
				{
					ListViewItem item = lstvwUserPermissoes.GetItemAt(e.X, e.Y);
					if (CanChangePermission(currentTipoFunction, colIndex))
						ChangePermission((GISADataset.TrusteeRow)item.Tag, currentTipoFunction, item, colIndex);
				}
			}
		}
示例#2
0
 private void m_lvProdutos_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
 {
     System.Windows.Forms.ListViewItem lviItemMouse;
     System.Drawing.Point ptMouse = m_lvProdutos.PointToClient(new System.Drawing.Point(e.X, e.Y));
     lviItemMouse = m_lvProdutos.GetItemAt(ptMouse.X, ptMouse.Y);
     if (lviItemMouse != null)
     {
         e.Effect = System.Windows.Forms.DragDropEffects.Copy;
     }
     else
     {
         e.Effect = System.Windows.Forms.DragDropEffects.None;
     }
 }
        /// <summary>
        /// Enables/disables items in the popup menu before it is displayed.
        /// </summary>
        private void ItemsLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // set default values.
            addMi_.Enabled      = itemsLv_.Items.Count < mTrend_.Items.Count;
            editMi_.Enabled     = false;
            removeMi_.Enabled   = false;
            copyDataMi_.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = itemsLv_.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked item.
            clickedItem.Selected = true;

            if (itemsLv_.SelectedItems.Count == 1)
            {
                editMi_.Enabled     = true;
                removeMi_.Enabled   = true;
                copyDataMi_.Enabled = typeof(TsCHdaItemValueCollection).IsInstanceOfType(clickedItem.Tag);
            }
        }
示例#4
0
        /// <summary>
        /// Enables/disables items in the popup menu before it is displayed.
        /// </summary>
        private void ItemListLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // disable everything.
            ViewMI.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = ItemListLV.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked node.
            clickedItem.Selected = true;

            if (ItemListLV.SelectedItems.Count == 1)
            {
                ViewMI.Enabled = (clickedItem.Tag != null && clickedItem.Tag.GetType() == typeof(TsCDaItemValueResult));
            }
        }
示例#5
0
        /// <summary>
        /// Enables/disables items in the popup menu before it is displayed.
        /// </summary>
        private void ItemsLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // set default values.
            AddMI.Enabled    = true;
            EditMI.Enabled   = false;
            RemoveMI.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = ItemsLV.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked item.
            clickedItem.Selected = true;

            if (ItemsLV.SelectedItems.Count == 1)
            {
                EditMI.Enabled   = true;
                RemoveMI.Enabled = true;
            }
        }
示例#6
0
        /// <summary>
        /// Enables/disables items in the popup menu before it is displayed.
        /// </summary>
        private void PropertiesLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // disable everything.
            viewMi_.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = propertiesLv_.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked node.
            clickedItem.Selected = true;

            if (propertiesLv_.SelectedItems.Count == 1)
            {
                viewMi_.Enabled = true;
            }
        }
        /// <summary>
        /// Enables/disables items in the popup menu before it is displayed.
        /// </summary>
        private void AttributesLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // set default values.
            addMi_.Enabled    = !ReadOnly && attributesLv_.Items.Count < mServer_.Attributes.Count;
            viewMi_.Enabled   = false;
            removeMi_.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = attributesLv_.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked item.
            clickedItem.Selected = true;

            if (attributesLv_.SelectedItems.Count == 1)
            {
                viewMi_.Enabled = true;
            }

            if (attributesLv_.SelectedItems.Count > 0)
            {
                removeMi_.Enabled = !ReadOnly;
            }
        }
示例#8
0
        /// <summary>
        /// Used to show the tool tip over the address book list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addressList_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            AddressBook.AddressBookProviderAddress address;
            ListViewItem item;

            item = addressList.GetItemAt(e.X, e.Y);
            if (item != null && addressList.Items.Count > 0)
            {
                address = item.Tag as AddressBook.AddressBookProviderAddress;

                if (item.Index != lastTipSel && address != null)
                {
                    lastTipSel = item.Index;

                    tip.Active = false;
                    tip.SetToolTip(addressList,
                                   address.name +
                                   localize.AGENT_DESKTOP_ADDR_BOOK_DLG_TOOLTIP_DEPT + address.department +
                                   localize.AGENT_DESKTOP_ADDR_BOOK_DLG_TOOLTIP_TITLE + address.title +
                                   localize.AGENT_DESKTOP_ADDR_BOOK_DLG_TOOLTIP_LOCATION + address.location +
                                   localize.AGENT_DESKTOP_ADDR_BOOK_DLG_TOOLTIP_PHONE + address.phone +
                                   localize.AGENT_DESKTOP_ADDR_BOOK_DLG_TOOLTIP_EMAIL + address.email);
                    tip.Active = true;
                }
            }
        }
示例#9
0
        private void lvwImages_DoubleClick(object sender, System.EventArgs e)
        {
            Point        cp   = lvwImages.PointToClient(new Point(MousePosition.X, MousePosition.Y));
            ListViewItem item = lvwImages.GetItemAt(cp.X, cp.Y);

            Process.Start(currentFolder + "\\" + item.Text);
        }
示例#10
0
        private Rectangle RetrieveCellBounds(int x, int y, ref ListViewItem rowItem, ref int index)
        {
            Rectangle r = new Rectangle(0, 0, 10, 10);
            Point     p = new Point(x, y);
//			p = listView1.PointToScreen(p);
            ListViewItem theCellRow = listView1.GetItemAt(5, p.Y);

            rowItem = theCellRow;
            if (theCellRow != null)
            {
                Rectangle rowRect = theCellRow.GetBounds(ItemBoundsPortion.ItemOnly);
                int       sum     = 0;
                for (int i = 0; i < listView1.Columns.Count; i++)
                {
                    ColumnHeader ch = listView1.Columns[i];
                    r = new Rectangle(rowRect.Left + sum, rowRect.Top, ch.Width, rowRect.Height);
                    if (r.Contains(p))
                    {
                        index = i;
                        return(r);
                    }
                    sum += listView1.Columns[i].Width;
                }
            }

            return(r);
        }
示例#11
0
        /// <summary>
        /// Called when someone drags something over our listview
        /// </summary>
        private void listView1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // Determine whether file data exists in the drop data. If not, then
            // the drop effect reflects that the drop cannot occur.
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            // Set the effect based upon the KeyState.
            // Can't get links to work - Use of Ole1 services requiring DDE windows is disabled
//			if ((e.KeyState & (CTRL | ALT)) == (CTRL | ALT) &&
//				(e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link)
//			{
//				e.Effect = DragDropEffects.Link;
//			}
//
//			else if ((e.KeyState & ALT) == ALT &&
//				(e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link)
//			{
//				e.Effect = DragDropEffects.Link;
//
//			}
//			else
            if ((e.KeyState & SHIFT) == SHIFT &&
                (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                e.Effect = DragDropEffects.Move;
            }
            else if ((e.KeyState & CTRL) == CTRL &&
                     (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                e.Effect = DragDropEffects.Copy;
            }
            else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                // By default, the drop action should be move, if allowed.
                e.Effect = DragDropEffects.Move;

                // Implement the rather strange behaviour of explorer that if the disk
                // is different, then default to a COPY operation
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (files.Length > 0 && !files[0].ToUpper().StartsWith(homeDisk) &&                                     // Probably better ways to do this
                    (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }

            // This is an example of how to get the item under the mouse
            Point        pt        = listView1.PointToClient(new Point(e.X, e.Y));
            ListViewItem itemUnder = listView1.GetItemAt(pt.X, pt.Y);
        }
示例#12
0
 private void listViewFile_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left &&
         listViewFile.SelectedItems.Count == 1 &&
         listViewFile.GetItemAt(e.X, e.Y) == listViewFile.SelectedItems[0])
     {
         HideAndOpenSelect();
     }
 }
示例#13
0
        private void ItemsLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            try
            {
                // ignore non-right clicks.
                if (e.Button == MouseButtons.Left)
                {
                    m_dragPosition = e.Location;
                    return;
                }

                // disable everything.
                if (ItemsLV.ContextMenuStrip != null)
                {
                    foreach (ToolStripItem item in ItemsLV.ContextMenuStrip.Items)
                    {
                        ToolStripMenuItem menuItem = item as ToolStripMenuItem;

                        if (menuItem == null)
                        {
                            continue;
                        }

                        menuItem.Enabled = false;

                        if (menuItem.DropDown != null)
                        {
                            foreach (ToolStripItem subItem in menuItem.DropDown.Items)
                            {
                                ToolStripMenuItem subMenuItem = subItem as ToolStripMenuItem;

                                if (subMenuItem != null)
                                {
                                    subMenuItem.Enabled = false;
                                }
                            }
                        }
                    }
                }

                // selects the item that was right clicked on.
                ListViewItem clickedItem = ItemsLV.GetItemAt(e.X, e.Y);

                // ensure clicked item is selected.
                if (clickedItem != null)
                {
                    clickedItem.Selected = true;
                }

                // enable menu items according to context.
                EnableMenuItems(clickedItem);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
示例#14
0
        private void listView1_MouseMove(object sender, MouseEventArgs e)
        {
            int idx = listView1.Items.IndexOf(listView1.GetItemAt(e.X, e.Y));

            //int idx = listView1.IndexFromPoint(e.X, e.Y);
            if (idx >= 0)
            {
                listView1.Items[idx].Selected = true;
            }
        }
        private void EditTeeBox(object sender, MouseEventArgs e)
        {
            ListViewItem l = lstTees.GetItemAt(e.X, e.Y);

            if (l != null)
            {
                MessageBox.Show("====== " + l.Text + " ======\n\n" +
                                "Add code or another dialog box here to edit \n" +
                                "the values for the subitems of this item");
            }
        }
示例#16
0
    private void ListView1_MouseDown(object sender, MouseEventArgs e)
    {
        ListViewItem selection = ListView1.GetItemAt(e.X, e.Y);

        // If the user selects an item in the ListView, display
        // the image in the PictureBox.
        if (selection != null)
        {
            PictureBox1.Image = System.Drawing.Image.FromFile(
                selection.SubItems[1].Text);
        }
    }
示例#17
0
        private void lvCharts_DoubleClick(object sender, System.EventArgs e)
        {
            Point        pos  = lvCharts.PointToClient(Cursor.Position);
            ListViewItem item = lvCharts.GetItemAt(pos.X, pos.Y);

            if (item != null && item.Tag != null)
            {
                _component.ChartControl = item.Tag;
                SetSelectedChart();
            }
            ;
        }
示例#18
0
        private void listView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListViewItem item = listView1.GetItemAt(e.X, e.Y);

            if (item == null)
            {
                return;
            }
            if (e.X < 17)
            {
                item.StateImageIndex = item.StateImageIndex == 1?0:1;
            }
        }
        /// <summary>
        /// Enables items in popup menu based on current selection.
        /// </summary>
        private void NotificationsLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // disable everything.
            viewMi_.Enabled        = false;
            acknowledgeMi_.Enabled = false;
            deleteMi_.Enabled      = false;
            clearAllMi_.Enabled    = true;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = notificationsLv_.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked node.
            clickedItem.Selected = true;

            // check for single selection.
            if (notificationsLv_.SelectedItems.Count == 1)
            {
                viewMi_.Enabled = true;
            }

            // check for multiple selection.
            if (notificationsLv_.SelectedItems.Count > 0)
            {
                acknowledgeMi_.Enabled = true;
                deleteMi_.Enabled      = true;

                // make sure all selected events require acknowledgement.
                foreach (ListViewItem item in notificationsLv_.SelectedItems)
                {
                    TsCAeEventNotification notification = (TsCAeEventNotification)item.Tag;

                    if (!notification.AckRequired)
                    {
                        acknowledgeMi_.Enabled = false;
                        break;
                    }
                }
            }
        }
示例#20
0
        //显示更新详细信息
        private void lvUpdateList_MouseMove(object sender, MouseEventArgs e)
        {
            ListViewItem item = lvUpdateList.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                tip.Show(lvUpdateList.Items[item.Index].SubItems[3].Text, lvUpdateList, new Point(e.X + 20, e.Y + 20), 15000);
                tip.Active = true;
            }
            else
            {
                tip.Active = false;
            }
        }
示例#21
0
        //x, y la client coordinate
        private void ListViewSelectAt(Point targetPoint)
        {
            // Select the item at the mouse position.
            listView1.MultiSelect = false;
            ListViewItem item = listView1.GetItemAt(targetPoint.X, targetPoint.Y);

            if (item == null)
            {
                return;
            }

            item.Selected = true;
            listView1.Select();
            //listView1.MultiSelect = true;
        }
示例#22
0
        private void listViewFaces_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
        {
            Point client = listViewFaces.PointToClient(new Point(e.X, e.Y));

            //	Are we dragging the sort of item we can take? (a string).
            ListViewItem itemOver = listViewFaces.GetItemAt(client.X, client.Y);

            //	Clear any items that might be selected.
            listViewFaces.SelectedItems.Clear();

            //	Select the item that is over.
            if (itemOver != null)
            {
                itemOver.Selected = true;
            }
        }
 private void OnListViewMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         ListViewItem item = _listView.GetItemAt(e.X, e.Y);
         if (item != null)
         {
             SnapInDescriptor descriptor = item.Tag as SnapInDescriptor;
             if (descriptor != null)
             {
                 this.UpdateContextMenu(descriptor);
                 _contextMenu.Show(_listView, new Point(e.X, e.Y));
             }
         }
     }
 }
示例#24
0
        private void listViewVertices_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (listViewVertices.Items.Count == 0)
            {
                return;
            }

            //	Get the item at the point clicked.
            ListViewItem item = listViewVertices.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                //	Start dragging and dropping.
                DragDropEffects effects = DoDragDrop(item.Text, DragDropEffects.Copy);
            }
        }
示例#25
0
        private void listView_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListViewItem item = listView.GetItemAt(e.X, e.Y);

            if (item != null && e.X >= nameColumn.Width)
            {
                BuildEventInfo info = item.Tag as BuildEventInfo;
                Graphics       g    = listView.CreateGraphics();
                if (g.MeasureString(info.Value, listView.Font).Width > valueColumn.Width)
                {
                    toolTip.SetToolTip(listView, info.Value);
                    return;
                }
            }

            toolTip.SetToolTip(listView, "");
        }
示例#26
0
        private void EntriesViewMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // create tooltip
            if (tip == null)
            {
                tip              = new ToolTip();
                tip.ShowAlways   = true;
                tip.AutoPopDelay = 10000;
            }
            // display entry details (filename, line, description)
            ListViewItem item = entriesView.GetItemAt(e.X, e.Y);

            if (item == null)
            {
                tip.SetToolTip(entriesView, "");
                return;
            }
            tip.SetToolTip(entriesView, String.Format("{1}, line {2}:\n{0}", item.SubItems[2].Text, item.SubItems[3].Text, item.SubItems[1].Text));
        }
示例#27
0
        private void listViewFaces_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListViewItem item = listViewFaces.GetItemAt(e.X, e.Y);

            if (item != null)
            {
                string tooltipText = String.Format("タイトル: {0}\n製作者: {1}\nバージョン: {2}",
                                                   item.Text, item.SubItems[2].Text, item.SubItems[3].Text);

                if (toolTipPreviewDetail.GetToolTip(listViewFaces) != tooltipText)
                {
                    toolTipPreviewDetail.SetToolTip(listViewFaces, tooltipText);
                }
            }
            else
            {
                // 消す。
                toolTipPreviewDetail.SetToolTip(listViewFaces, "");
            }
        }
示例#28
0
        /// <summary>
        /// Enables items in popup menu based on current selection.
        /// </summary>
        private void ArrayLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // disable everything.
            ViewMI.Enabled   = false;
            InsertMI.Enabled = false;
            DeleteMI.Enabled = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = ArrayLV.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked node.
            clickedItem.Selected = true;

            // check for single selection on an array element.
            if (ArrayLV.SelectedItems.Count == 1)
            {
                if (clickedItem.Tag != null && clickedItem.Tag.GetType().IsArray)
                {
                    ViewMI.Enabled = true;
                }
            }

            // check for any selection.
            if (ArrayLV.SelectedItems.Count > 0)
            {
                InsertMI.Enabled = !m_readOnly;
                DeleteMI.Enabled = !m_readOnly;
            }
        }
示例#29
0
        private void messagesListView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            OnMouseDown(e);

            if (messagesListView.GetItemAt(e.X, e.Y) != null)
            {
                // Remember the point where the mouse down occurred. The DragSize indicates
                // the size that the mouse can move before a drag event should be started.
                Size dragSize = SystemInformation.DragSize;

                // Create a rectangle using the DragSize, with the mouse position being
                // at the center of the rectangle.
                _dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2),
                                                                e.Y - (dragSize.Height / 2)), dragSize);
            }
            else
            {
                // Reset the rectangle if the mouse is not over an item in the ListBox.
                _dragBoxFromMouseDown = Rectangle.Empty;
            }
        }
示例#30
0
        /// <summary>
        /// Enables items in popup menu based on current selection.
        /// </summary>
        private void AreaSourceLV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // disable everything.
            addSourceMi_.Enabled = false;
            addAreaMi_.Enabled   = false;
            editMi_.Enabled      = false;
            deleteMi_.Enabled    = false;

            // selects the item that was right clicked on.
            ListViewItem clickedItem = areaSourceLv_.GetItemAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedItem == null)
            {
                return;
            }

            // force selection to clicked node.
            clickedItem.Selected = true;

            // enable everything.
            addSourceMi_.Enabled = true;
            addAreaMi_.Enabled   = true;

            if (areaSourceLv_.SelectedItems.Count == 1)
            {
                editMi_.Enabled = true;
            }

            if (areaSourceLv_.SelectedItems.Count > 0)
            {
                deleteMi_.Enabled = true;
            }
        }
        private ListViewItem GetListViewItemAt(ListView listView, Point pos)
        {
            // Returns the location of the mouse pointer in the ListView control.
            Point cp = listView.PointToClient(pos);

            // Obtain the item that is located at the specified location of the mouse pointer.
            return listView.GetItemAt(cp.X, cp.Y);
        }
示例#32
0
        private void listItem(ListView listView, MouseEventArgs e)
        {
            ListViewItem item = listView.GetItemAt(e.X, e.Y);
            if (item != null)
            {

                item.Selected = true;
                var obj = new Popup();
                obj.textBox1 = item.SubItems[0].Text;
                obj.textBox2 = item.SubItems[1].Text;
                obj.textBox3 = item.SubItems[2].Text;
                obj.textBox4 = item.SubItems[3].Text;
                obj.textBox5 = item.SubItems[4].Text;
                obj.textBox6 = item.SubItems[5].Text;
                obj.textBox7 = item.SubItems[6].Text;
                obj.textBox8 = item.SubItems[7].Text;
                obj.textBox9 = item.SubItems[8].Text;
                obj.textBox10 = item.SubItems[9].Text;
                obj.recevoirListView();
                obj.ShowDialog();
                refresh();

            }

            else if ( item == null )
            {
                var obj = new Popup();
                obj.textBox1 = "Michaux";
                obj.textBox2 = "Samuel";
                obj.textBox3 = "*****@*****.**";
                obj.textBox4 = "0642958853";
                obj.textBox5 = "0642958853";
                obj.textBox6 = "71";
                obj.textBox7 = "Rue Jean Jacques Rousseau";
                obj.textBox8 = "59260";
                obj.textBox9 = "Hellemmes";
                obj.textBox10 = "Appartement 1";
                obj.recevoirListView();
                obj.ShowDialog();
                refresh();
            }
        }
示例#33
0
        /// <summary>
        /// Returns the item in the given ListView under the cursor.
        /// </summary>
        private ListViewItem getItemUnderMouse( ListView list, int x, int y )
        {
            // Get the coordinates relative to the control.
            Point localPoint = list.PointToClient( new Point( x, y ) );

            return list.GetItemAt( localPoint.X, localPoint.Y );
        }
示例#34
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lv"></param>
        /// <param name="lst"></param>
        /// <param name="x">鼠标的x坐标</param>
        /// <param name="y">鼠标的y坐标</param>
        /// <param name="col">ComboBox显示在哪个列上</param>
        /// <param name="defaultValueCol">ComboBox的默认值列</param>
        private static void ShowCombobox(ListView lv, ComboBox lst, int x, int y, int col, int defaultValueCol)
        {
            var item = lv.GetItemAt(x, y);
            if (item == null || !item.Checked)
                return;
            comboboxItem = item;

            int lWidth = 0, rWidth = 0;
            for (int i = 0; i <= col; i++)
            {
                int tmp = lv.Columns[i].Width;
                if (i < col)
                    lWidth += tmp;
                rWidth += tmp;
            }

            if (x > rWidth || x < lWidth)
            {
                lst.Visible = false;
                return;
            }

            //获取所在位置的行的Bounds            
            Rectangle rect = item.Bounds;
            //修改Rect的范围使其与第二列的单元格的大小相同,为了好看 ,左边缩进了2个单位                       
            rect.X += lv.Left + lWidth + 2;
            rect.Y += lv.Top + 2;
            rect.Width = rWidth - lWidth;
            lst.Bounds = rect;
            string val = item.SubItems[col].Text;
            if (string.IsNullOrEmpty(val) && defaultValueCol >= 0 && item.SubItems.Count > defaultValueCol)
                val = item.SubItems[defaultValueCol].Text;
            lst.Text = val;
            lst.Visible = true;
            lst.BringToFront();
            lst.Focus();
            lst.Name = col.ToString();

            //lst.SelectedIndexChanged -= lstSelectedIndexChanged;// (obj, args) => { MessageBox.Show("1"); };
        }
示例#35
0
        // 获取鼠标所在的列号
        private static int GetMouseCol(ListView lv, int x, int y, out int lWidth, out int rWidth)
        {
            lWidth = rWidth = 0;
            var item = lv.GetItemAt(x, y);
            if (item == null || !item.Checked)
                return -1;
            comboboxItem = item;

            for (int i = 0; i < item.SubItems.Count; i++)
            {
                int tmp = lv.Columns[i].Width;
                rWidth += tmp;
                if (x <= rWidth && x >= lWidth)
                    return i;

                lWidth = rWidth;
            }
            return -1;
        }