コード例 #1
0
 //this magically makes the context menu appear on row right-click.
 protected override void OnCellContextMenuStripNeeded(DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (RowContextMenuStrip != null && e.RowIndex >= 0)
     {
         e.ContextMenuStrip = RowContextMenuStrip;
     }
     base.OnCellContextMenuStripNeeded(e);
 }
コード例 #2
0
        /// <summary>
        /// 設定ProcedureTable的左鍵表單
        /// </summary>
        private void ProcedureTable_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            //將object sender轉換成 DataGridView dgv
            DataGridView dgv = (DataGridView)sender;
            //清除選項
            dgv.ClearSelection();
            //選擇一整列
            dgv.Rows[e.RowIndex].Selected = true;

            //表單控制項(現在選在哪一格上)
            CurrencyManager cm = (CurrencyManager)this.BindingContext[Camera.Procedure];
            //滑鼠的row傳給cm 顯示控制
            cm.Position = e.RowIndex;

            if (e.RowIndex < 0 && e.ColumnIndex > 0)
            {
                //表單標頭備用
            }
            else if (e.ColumnIndex < 0 && e.RowIndex > 0)
            {
                //表單標頭備用
            }
            else if (e.RowIndex == 0 )
            {
                //第一ROW 不能刪除
                PrcedureMenuStrip.Items[1].Enabled = false;
                e.ContextMenuStrip = this.PrcedureMenuStrip;


            }
            else
            {
                //右鍵Prcedure表單
                PrcedureMenuStrip.Items[1].Enabled = true;
                e.ContextMenuStrip = this.PrcedureMenuStrip;
                
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Mcafee123/ResxTranslator
        private void dataGridView1_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            if (e.ColumnIndex < 0)
            {
                return;
            }
            e.ContextMenuStrip = this.contextMenuStripCell;

            var autoTranslate = this.contextMenuStripCell.Items["autoTranslateThisCellToolStripMenuItem"] as ToolStripMenuItem;

            if (autoTranslate.DropDownItems.Count < 3)
            {
                //rebuild the language select drop down
                int subChk = FindCheckedSubItemIndex(autoTranslate);
                string chkedLang = "";
                if (subChk > -1)
                {
                    chkedLang = autoTranslate.DropDownItems[subChk].Text;
                }
                else
                {
                    (autoTranslate.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                }

                for (int i = autoTranslate.DropDownItems.Count - 1; i > 1; --i)
                {
                    autoTranslate.DropDownItems.RemoveAt(i);
                }

                foreach (var lang in this.CurrentResource.Languages.Keys)
                {
                    autoTranslate.DropDownItems.Add(lang);
                    var newItem = (autoTranslate.DropDownItems[autoTranslate.DropDownItems.Count - 1] as ToolStripMenuItem);
                    if (chkedLang == lang)
                    {
                        newItem.Checked = true;
                    }
                }
            }

            var preferred = "NoLanguageValue";
            if (!(autoTranslate.DropDownItems[1] as ToolStripMenuItem).Checked)
            {
                int subChk = FindCheckedSubItemIndex(autoTranslate);
                if (subChk > -1)
                {
                    preferred = autoTranslate.DropDownItems[subChk].Text;
                }
            }

            this.dataGridView1.CurrentCell = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
            string source = this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells[preferred].Value.ToString();
            int colIndex = this.dataGridView1.CurrentCell.ColumnIndex;
            string column = this.dataGridView1.Columns[colIndex].Name;

            List<string> listofalternatives = InprojectTranslator.Instance.GetTranslations(this.CurrentResource.NoLanguageLanguage, source, column);
            for (int i = e.ContextMenuStrip.Items.Count - 1; i > 0; --i)
            {
                if (e.ContextMenuStrip.Items[i].Name.StartsWith("Transl"))
                {
                    e.ContextMenuStrip.Items.RemoveAt(i);
                }
            }
            foreach (string alt in listofalternatives)
            {
                e.ContextMenuStrip.Items.Add(alt);
                ToolStripItem newItem = e.ContextMenuStrip.Items[e.ContextMenuStrip.Items.Count - 1];
                string translation = alt;
                DataGridViewCell cell = this.dataGridView1.CurrentCell;
                newItem.Click += (EventHandler)delegate
                                               {
                                                   cell.Value = translation;
                                                   this.dataGridView1.EndEdit();
                                               };
                newItem.Name = "Transl_" + alt;
            }
        }
コード例 #4
0
ファイル: JobsView.cs プロジェクト: thinkingmedia/gems
 /// <summary>
 /// Gets the context menu for a job or task.
 /// </summary>
 private void onContextMenuNeeded(object pSender,
                                  DataGridViewCellContextMenuStripNeededEventArgs pEvent)
 {
     view.Rows[pEvent.RowIndex].Cells[pEvent.ColumnIndex].Selected = true;
     pEvent.ContextMenuStrip = pEvent.ColumnIndex < _INFO_COLUMNS
         ? _jobMenu
         : _taskMenu;
 }
コード例 #5
0
ファイル: LogWindow.cs プロジェクト: gspatace/logexpert
 void FilterGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (e.ContextMenuStrip == columnContextMenuStrip)
     {
         _selectedCol = e.ColumnIndex;
     }
 }
コード例 #6
0
 private void dgv_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
         dgv.CurrentCell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
 }
コード例 #7
0
        /// <summary>
        /// 設定MainWindowObjectTable的左鍵表單
        /// </summary>
        private void MainWindowObjectTable_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            //將object sender轉換成 DataGridView dgv
            DataGridView dgv = (DataGridView)sender;
            //清除選項
            dgv.ClearSelection();
            //選擇一整列
            dgv.Rows[e.RowIndex].Selected = true;

            //表單控制項(現在選在哪一格上)
            CurrencyManager cm = (CurrencyManager)this.BindingContext[Camera.Object];
            //滑鼠的row傳給cm 顯示控制
            cm.Position = e.RowIndex;

            if (e.RowIndex < 0)
            {
                //表單標頭備用
            }
            else if (e.ColumnIndex < 0)
            {
                //表單標頭備用
            }
            else
            {
                //右鍵Object表單
                e.ContextMenuStrip = this.ObjectMenuStrip;
            }
        }
コード例 #8
0
 private void dgvSalesQuotationRegister_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
 }
コード例 #9
0
 [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")] // e.ColumnIndex / e.RowIndex is more precise than just e
 protected virtual void OnCellContextMenuStripNeeded(DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (e.ColumnIndex >= this.Columns.Count)
     {
         throw new ArgumentOutOfRangeException("e.ColumnIndex");
     }
     if (e.RowIndex >= this.Rows.Count)
     {
         throw new ArgumentOutOfRangeException("e.RowIndex");
     }
     DataGridViewCellContextMenuStripNeededEventHandler eh = this.Events[EVENT_DATAGRIDVIEWCELLCONTEXTMENUSTRIPNEEDED] as DataGridViewCellContextMenuStripNeededEventHandler;
     if (eh != null && !this.dataGridViewOper[DATAGRIDVIEWOPER_inDispose] && !this.IsDisposed)
     {
         eh(this, e);
     }
 }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: kevinmmccormick/POGS
 private void clientListDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         e.ContextMenuStrip = clientContextMenuStrip;
     }
 }
コード例 #11
0
ファイル: CellUI.cs プロジェクト: thawk/structorian
 public void ContextMenuStripNeeded(DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     var strip = new ContextMenuStrip();
     strip.Items.Add(new ToolStripMenuItem("Save Data...", null, SaveData));
     e.ContextMenuStrip = strip;
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: SaintLoong/TDTK.MSCM
 /// <summary>
 /// 传感器设置--点击某个单元格
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataGridView_devName_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     cIndex = e.RowIndex;
     dgvrc = null;
     if (e.RowIndex >= 0)
     {
         DataGridView dgv = sender as DataGridView;
         dgvrc = dgv.Rows[e.RowIndex];
     }
 }
コード例 #13
0
ファイル: Form1.cs プロジェクト: sirrocco/SqlScriptRunner
 private void GvFilesCellContextMenuStripNeeded( object sender, DataGridViewCellContextMenuStripNeededEventArgs e )
 {
     _rowIndexLastClicked = e.RowIndex;
 }
コード例 #14
0
        private void gvSearchResults_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            Peter.ShellContextMenu ctxMenu = new Peter.ShellContextMenu();
            FileInfo[] arrFI = new FileInfo[1];
            DataGridViewRow curRow;
            String filePath;

            if (e.RowIndex >= 0 && gvSearchResults.Rows.Count>0)
            {
                curRow = gvSearchResults.Rows[e.RowIndex];
                filePath = (String)curRow.Cells["colPath"].Value + "\\" + (String)curRow.Cells["colName"].Value;
                arrFI[0] = new FileInfo(filePath);
                ctxMenu.ShowContextMenu(arrFI, MousePosition);
            }
        }
コード例 #15
0
ファイル: DataView.cs プロジェクト: thawk/structorian
 private void _structGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (_structGridView.SelectedRows.Count > 0)
     {
         StructCell cell = (StructCell) _structGridView.SelectedRows[0].DataBoundItem;
         CellUI ui = CellUIRegistry.GetUI(cell);
         if (ui != null)
         {
             ui.ContextMenuStripNeeded(e);
         }
         else
         {
             e.ContextMenuStrip = contextMenuStrip1;
         }
     }
 }
コード例 #16
0
 protected virtual void OnCellContextMenuStripNeeded(DataGridViewCellContextMenuStripNeededEventArgs e);
コード例 #17
0
 internal ContextMenuStrip OnCellContextMenuStripNeeded(int columnIndex, int rowIndex, ContextMenuStrip contextMenuStrip)
 {
     DataGridViewCellContextMenuStripNeededEventArgs dgvccmsne = new DataGridViewCellContextMenuStripNeededEventArgs(columnIndex, rowIndex, contextMenuStrip);
     OnCellContextMenuStripNeeded(dgvccmsne);
     return dgvccmsne.ContextMenuStrip;
 }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: kevinmmccormick/POGS
        private void fieldsDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex == 1)
            {
                e.ContextMenuStrip = fieldMenuStrip;

                var cell = fieldsDataGridView[e.ColumnIndex, e.RowIndex];

                var fieldRow = fieldsDataGridView.Rows[e.RowIndex].DataBoundItem as EntryFieldRow;

                openSiteInBrowserToolStripMenuItem.Visible = cell.Value != null && (fieldRow != null && fieldRow.SourceField.EntryType == EntryFieldType.Website);
                if (cell.Value != null)
                {
                    string cellValue = cell.Value.ToString();
                    if (cellValue.Length > 18)
                        cellValue = cellValue.Substring(0, 18);

                    openSiteInBrowserToolStripMenuItem.Text = String.Format("Visit {0}...", cellValue);
                }
            }
        }
コード例 #19
0
        private void dataGridView1_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                columnContextMenuStrip.Tag = e.ColumnIndex;

                foreach (ToolStripMenuItem item in autoSizeModeToolStripMenuItem.DropDownItems)
                {
                    if (item.Tag.ToString() == dataGridView1.Columns[e.ColumnIndex].AutoSizeMode.ToString())
                        item.Checked = true;
                    else
                        item.Checked = false;
                }

                e.ContextMenuStrip = columnContextMenuStrip;
            }
            else
            {
                cellContextMenuStrip.Tag = String.Format("{0} {1}", e.ColumnIndex, e.RowIndex);
                e.ContextMenuStrip = cellContextMenuStrip;
            }
        }
コード例 #20
0
ファイル: GRINGlobalSearch.cs プロジェクト: egacheru/G2
 private void ux_datagridviewQueryResults_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     MouseClickColumnIndex = e.ColumnIndex;
     MouseClickRowIndex = e.RowIndex;
 }
コード例 #21
0
ファイル: Form2.cs プロジェクト: SislanERP/TarjetaMantenedor
 private void gridUsuarios_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
 }
コード例 #22
0
ファイル: GRINGlobalSearch.cs プロジェクト: egacheru/G2
 private void ux_datagridviewSearchCriteria_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     ux_datagridviewSearchCriteria.CurrentCell = ux_datagridviewSearchCriteria[e.ColumnIndex, e.RowIndex];
 }
コード例 #23
0
        // 右クリックメニューが表示される前に実行されるイベント
        private void dataGridViewList_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            // ヘッダセル以外の場合
            if(e.ColumnIndex >= 0 && e.RowIndex >= 0){
                var dgv = (DataGridView)sender;

                // 右クリックされたセルを取得
                DataGridViewCell cell = dgv[e.ColumnIndex, e.RowIndex];

                // セルを選択状態にする
                cell.Selected = true;

                var uid = dgv.Rows[e.RowIndex].Cells["UID"].Value.ToString();

                this.selectedUid = uid;
            }
        }
コード例 #24
0
 private void dataGridView1_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     cellContextMenuStrip.Tag = String.Format("{0} {1}", e.ColumnIndex, e.RowIndex);
     e.ContextMenuStrip = cellContextMenuStrip;
 }
コード例 #25
0
ファイル: LogWindow.cs プロジェクト: gspatace/logexpert
 void DataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     if (e.RowIndex > 0 && e.RowIndex < dataGridView.RowCount &&
         !dataGridView.Rows[e.RowIndex].Selected)
     {
         SelectLine(e.RowIndex, false);
     }
     if (e.ContextMenuStrip == columnContextMenuStrip)
     {
         _selectedCol = e.ColumnIndex;
     }
 }
コード例 #26
0
 private void gridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     contextColumnIndex = e.ColumnIndex;
       contextRowIndex = e.RowIndex;
       if (e.RowIndex == -1)
       {
     e.ContextMenuStrip = (e.ColumnIndex == -1) ? null : get_column_header_right_click_menu(contextColumnIndex);
       }
       else
       {
     int column = -1;
     List<int> rows = gridView.GetSelectedRowsCol(ref column);
     e.ContextMenuStrip = model.get_context_menu(rows, column);
       }
 }
コード例 #27
0
ファイル: DataViewer.cs プロジェクト: egacheru/G2
        private void ux_datagridviewMain_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            // Set the global variables so that later processing will know where to apply the command from the context menu...
            mouseClickDGVColumnIndex = e.ColumnIndex;
            mouseClickDGVRowIndex = e.RowIndex;

            // Change the color of the cell background so that the user
            // knows what cell the context menu applies to...
            if (e.RowIndex > -1 && e.ColumnIndex > -1)
            {
                ux_datagridviewMain.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Red;
                ux_datagridviewMain.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionBackColor = Color.Red;
            }

            // Clear the reports tool strip menu items and get a fresh list from the Reports directory...
            ux_dgvcellmenuReports.DropDownItems.Clear();

            // There are lots of ways to get the Reports directory location (the cleanest is to find the CT directory and go from there)...
            // So... Here are some of the better ways to find the CT's EXE path:
            //      System.Environment.GetFolderPath(System.Reflection.Assembly.GetExecutingAssembly().Location)
            //      System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)
            //      System.Windows.Forms.Application.StartupPath
            //      System.IO.Directory.GetCurrentDirectory()  <-- this one changes if the user saves an export of a report from CR Viewer

            ////System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()); //System.Environment.GetFolderPath(Environment.SpecialFolder. System.Reflection.Assembly.GetExecutingAssembly()..Location);
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.Windows.Forms.Application.StartupPath + "\\Reports");
            System.Collections.Generic.Dictionary<string, string> reportsMap = _sharedUtils.GetReportsMapping();
            string dataviewName = ((DataviewProperties)ux_tabcontrolCTDataviews.SelectedTab.Tag).DataviewName.Trim().ToUpper();
            foreach (System.IO.FileInfo fi in di.GetFiles("*.rpt", System.IO.SearchOption.AllDirectories))
            {
            if (reportsMap.ContainsKey(fi.Name.Trim().ToUpper()) &&
            reportsMap[fi.Name.Trim().ToUpper()].Contains(" " + dataviewName + " "))
            {
            ToolStripItem tsi = ux_dgvcellmenuReports.DropDownItems.Add(fi.Name, null, ux_DGVCellReport_Click);
            tsi.Tag = fi.FullName;
            }
            }
            if (ux_dgvcellmenuReports.DropDownItems.Count > 0)
            {
            ux_dgvcellmenuReports.Enabled = true;
            }
            else
            {
            ux_dgvcellmenuReports.Enabled = false;
            }
            // Enable/Disable the Change Ownership menu selection based on if the user owns all of the rows...
            bool userOwnsAllRows = false;
            string cooperator = _usernameCooperatorID;
            // If the DGV is in read-only mode use the display value - not the cooperator_id for comparison...
            if (ux_buttonEditData.Enabled)
            {
                cooperator = _sharedUtils.GetLookupDisplayMember("cooperator_lookup", _usernameCooperatorID, "", _usernameCooperatorID);
            }
            // Now iterate through the selected rows to make sure the current user owns all of them...
            if (ux_datagridviewMain.Columns.Contains("owned_by"))
            {
                // Assume the user owns all the rows until proven otherwise...
                userOwnsAllRows = true;
                foreach (DataGridViewRow dgvr in ux_datagridviewMain.SelectedRows)
                {
                    if (((DataRowView)dgvr.DataBoundItem).Row["owned_by"].ToString() != cooperator) userOwnsAllRows = false;
                }
            }
            ux_dgvcellmenuChangeOwner.Enabled = userOwnsAllRows;
        }
コード例 #28
0
 private void dataGridPlayers_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     Console.WriteLine(e.RowIndex + "," + e.ColumnIndex);
     dataGridPlayers.Tag = new int[] { e.RowIndex, e.ColumnIndex };
 }
コード例 #29
0
ファイル: DataGridView.cs プロジェクト: vnan122/mono
		protected virtual void OnCellContextMenuStripNeeded (DataGridViewCellContextMenuStripNeededEventArgs e)
		{
			DataGridViewCellContextMenuStripNeededEventHandler eh = (DataGridViewCellContextMenuStripNeededEventHandler)(Events [CellContextMenuStripNeededEvent]);
			if (eh != null)
				eh (this, e);
		}
コード例 #30
0
 // Display helper for Row Context Menu, display only if clicked on row
 // used as property of datagridview always displays the contextmenu
 private void parsedFilesGridView_showContextMenu(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
 {
     e.ContextMenuStrip = this.parsedFileContextMenu;
     this.parsedFilesGridView.Rows[e.RowIndex].Selected = true;
 }