1
Answer

Do not close ContextMenuStrip

Photo of Eyal Lewin

Eyal Lewin

15y
5.7k
1
Hello,
i have a treeView component where a ContextMenuStrip is already assigned to it (ex. contextP)
now, i want to drag a node from one place to another in the treeView.
when i do so, i call the DragDrop event which has all my function's according to my needs.
in this event, i would like to call a different ContextMenuStrip named contextD.
i thought of using
 .
.
.
contextD.Show(Point pt);
.
.
.

private void contextD_Opening(object sender, CancelEventArgs e)
{
ToolStripMenuItem itemMove = (ToolStripMenuItem)contextDrag.Items["ctextMoveItem"];
ToolStripMenuItem itemCopy = (ToolStripMenuItem)contextDrag.Items["ctextCopyItem"];
ToolStripMenuItem itemCancel = (ToolStripMenuItem)contextDrag.Items["ctextCancelItem"];
}


but when the opening event has finished, the main code continues, and the contextD is still shown, regardless to my selection.

how can i make the contextD to stay on, depending on my selection in the menu to continue my flow (do event's etc.) ?
then of course, how to close it when im finished with it ?

thanks
Eyal

Answers (1)

0
Photo of Administrator
Admin 2.3k 1.3m 22y
But if You use sorting or filtering in DataGrid use DataView instead of DataTable. The simple solution (not tested, when it works): myDataGrid.DefaultView[myRow].Row[myField] or more complicated - create Your own property in object inherited from DataGrid: public DataView GridView { get { try { return (DataView)(this.ListManager.List); } catch { return null; } } } and use it: myDataGrid.GridView[myRow].Row[myField]
0
Photo of Administrator
Admin 2.3k 1.3m 22y
Los_Calibra First get the Row number of the selected row: int gridRow = dataGrid1.CurrentCell.RowNumber Next get the DateSource : DataTable dt = ((DataSet)dataGrid1.DataSource).Tables["My_Table"]; Now get the value: dt.Rows[gridRow]["Column_Name"] Hope this Helps
0
Photo of Administrator
Admin 2.3k 1.3m 22y
When You select only one row (standard in DataGrid) it's quite good. Next - you may create inherited DataGrid and override select methods (with "new" keyword; usual overriding is impossible). Now I'm trying to do this. I use four methods: public new void Select(int row){ ... } public new void UnSelect(int row){ ... } public new bool IsSelected(int row){ ... } protected new void ResetSelection(){ ... } It works, but not always - it's necessary to find another methods/properties to override I think. You may create your own event OnSelection etc. in these methods (or create your own delegate with another parameters): public event EventHandler OnSelection; and use it: if(OnSelection!=null) OnSelection(this);
0
Photo of Administrator
Admin 2.3k 1.3m 22y
At this point I have this problem: How can I get the data object behind the currently selected row of a DataGrid WinControl. How can I retrive the value of a specific field what corespond to that selected row - for example value for IDField who does'nt have a reprezentative column in that DataGrid. A C# example will be good!
0
Photo of Administrator
Admin 2.3k 1.3m 22y
CurrentCellChanged CurrentCell.RowNumber