// show context menu when user presses the right button
        private void _flex_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // hide current note, if any
                if (_note != null)
                {
                    _note.HideNote();
                    _note = null;
                }

                // make sure user clicked a valid cell
                int row = _flex.MouseRow;
                int col = _flex.MouseCol;
                if (row >= _flex.Rows.Fixed && col >= _flex.Cols.Fixed)
                {
                    // select cell that was clicked
                    _flex.Select(row, col);

                    // update context menu
                    bool hasNote = GetNoteAtMouse() != null;
                    _mInsertNote.Visible = !hasNote;
                    _mEditNote.Visible   = hasNote;
                    _mDeleteNote.Visible = hasNote;

                    // show the menu
                    _menuActive = true;
                    _menu.Show(_flex, new Point(e.X, e.Y));
                    //Application.DoEvents();
                    _menuActive = false;
                }
            }
        }
        private void _mInsertNote_Click(object sender, System.EventArgs e)
        {
            // create note
            CellNote1 note = new CellNote1("Note: ");

            // attach note to cell
            CellRange rg = _flex.Selection;

            rg.UserData = note;
            _flex.Invalidate();

            // go edit the new note
            _mEditNote_Click(sender, e);
        }
        //------------------------------------------------------------------------------------------------------
        #region ** menu event handlers

        private void _mDeleteNote_Click(object sender, System.EventArgs e)
        {
            // get note
            CellRange rg   = _flex.Selection;
            CellNote1 note = rg.UserData as CellNote1;

            // clear note
            if (note != null)
            {
                rg.UserData = null;
                _flex.Invalidate();
            }

            // resume showing notes
            _menuActive = false;
        }
        private void _mEditNote_Click(object sender, System.EventArgs e)
        {
            // get note
            CellRange rg   = _flex.Selection;
            CellNote1 note = rg.UserData as CellNote1;

            // edit note
            if (note != null)
            {
                Rectangle r = _flex.GetCellRect(rg.r1, rg.c1);
                r = _flex.RectangleToScreen(r);
                note.EditNote(r);
            }

            // resume showing notes
            _menuActive = false;
        }
        //------------------------------------------------------------------------------------------------------
        #region ** grid event handlers

        // show/hide cell notes
        private void _flex_MouseHoverCell(object sender, System.EventArgs e)
        {
            // hide current note, if any
            if (_note != null)
            {
                _note.HideNote();
                _note = null;
            }

            // don't show note if the grid is not focused or if the context menu is active
            if (!_flex.Focused || _menuActive)
            {
                return;
            }

            // show new note, if any
            _note = GetNoteAtMouse();
            if (_note != null)
            {
                Rectangle r = _flex.GetCellRect(_flex.MouseRow, _flex.MouseCol);
                r = _flex.RectangleToScreen(r);
                _note.ShowNote(r);
            }
        }