Esempio n. 1
0
        // show hyperlink cursor
        private void _flex_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            HitTestInfo ht   = _flex.HitTest(e.X, e.Y);
            bool        hand = false;

            if (ht.Type == HitTestTypeEnum.Cell)
            {
                Hyperlink link = _flex[ht.Row, ht.Column] as Hyperlink;
                if (link != null)
                {
                    using (Graphics g = _flex.CreateGraphics())
                    {
                        Rectangle rc    = _flex.GetCellRect(ht.Row, ht.Column, false);
                        int       width = (int)g.MeasureString(link.ToString(), _flex.Font).Width;
                        if (e.X - rc.Left <= width)
                        {
                            hand = true;
                        }
                    }
                }
            }
            Cursor = (hand)? Cursors.Hand: Cursors.Default;
        }
Esempio n. 2
0
        private void Init()
        {
            // initialize child flex control control
            _flex = new C1.Win.C1FlexGrid.C1FlexGrid();
            ((System.ComponentModel.ISupportInitialize)(this._flex)).BeginInit();
            _flex.Dock          = DockStyle.Fill;
            _flex.BorderStyle   = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            _flex.SelectionMode = SelectionModeEnum.Row;
            _flex.FocusRect     = FocusRectEnum.None;
            _flex.AllowEditing  = false;
            _flex.AutoSearch    = AutoSearchEnum.FromCursor;
            _flex.Rows.Count    = rs.rows + 1;
            _flex.Cols.Fixed    = 0;
            _flex.KeyActionTab  = KeyActionEnum.MoveDown;
            _flex.TabIndex      = 0;
            _flex.Font          = _ctl.Font;
            _flex.Styles        = _ctl.Styles;
            ((System.ComponentModel.ISupportInitialize)(this._flex)).EndInit();
            _flex.Cols.Count = _cols;
            for (int c = 0; c < _cols; c++)
            {
                _flex.Cols[c].Name    = rs.Field(c);
                _flex.Cols[c].Caption = Function.PublicFunction.L_GetLabel_VS(LabelID, _flex.Cols[c].Name);
            }

            // populate child flex control control
            for (int r = 0; r < rs.rows; r++)
            {
                for (int c = 0; c < _cols; c++)
                {
                    _flex[r + 1, c] = rs.record(r, c);
                }
            }

            // initialize selection
            _flex.Row = -1;
            string s = _ctl.GetDataDisplay(_row, _col);

            for (int r = 1; r < _flex.Rows.Count && _flex.Row < 0; r++)
            {
                if (_flex.GetDataDisplay(r, 0) == s)
                {
                    _flex.Row = r;
                }
            }

            // initialize form
            Controls.Add(_flex);
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            StartPosition   = FormStartPosition.Manual;

            //SystemInformation.MaxWindowTrackSize.IsEmpty ;
            //MessageBox.Show(""+SystemInformation.MaxWindowTrackSize.Height);
            //MessageBox.Show(""+System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height);


            // set form size
            _flex.AutoSizeCols(4);
            int rows = Math.Min(10, _flex.Rows.Count);
            int cols = _flex.Cols.Count;
            int wid  = _flex.Cols[cols - 1].Right + 2;
            int hei  = rows * _flex.Rows.DefaultSize + 2;

            if (rows < _flex.Rows.Count)
            {
                wid += SystemInformation.VerticalScrollBarWidth;
            }
            ClientSize = new Size(wid, hei);

            int ww = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int hh = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            int x, y;

            // set form location
            Rectangle rc = _ctl.GetCellRect(_row, _col, true);

            rc = _ctl.RectangleToScreen(rc);
            if ((rc.Left + wid) < ww - 50)
            {
                x = rc.Left;
            }
            else
            {
                x = rc.Right - wid;
            }

            if ((rc.Bottom + hei) < hh - 50)
            {
                y = rc.Bottom;
            }
            else
            {
                y = rc.Top - hei;
            }

            Location = new Point(x, y);



            // initialize event handlers
            Deactivate    += new System.EventHandler(_flex_Click);
            _flex.Click   += new System.EventHandler(_flex_Click);
            _flex.KeyDown += new System.Windows.Forms.KeyEventHandler(_flex_KeyDown);
        }