Example #1
0
        /// <summary>Handle mouse click within the trade grid</summary>
        private void HandleMouseClick(object sender, MouseEventArgs e)
        {
            var hit = m_grid.HitTestEx(e.X, e.Y);

            if (!m_grid.Within(hit.ColumnIndex, hit.RowIndex))
            {
                return;
            }

            // Ensure the clicked row is selected
            if (!m_grid.Rows[hit.RowIndex].Selected)
            {
                m_grid.ClearSelection();
                m_grid.Rows[hit.RowIndex].Selected = true;
            }

            // Get the data bound item
            var trade = ((TreeGridNode)m_grid.Rows[hit.RowIndex]).DataBoundItem as Trade;
            var order = ((TreeGridNode)m_grid.Rows[hit.RowIndex]).DataBoundItem as Order;

            // Show the context menu on right mouse click
            if (e.Button == MouseButtons.Right)
            {
                ShowContextMenu(hit, trade, order);
            }
        }