/// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void ChangeZoomPercent(float oldFactor, float newFactor)
        {
            Font oldFont = m_dataGridView.DefaultCellStyle.Font;

            m_dataGridView.DefaultCellStyle.Font = new Font(oldFont.FontFamily,
                                                            m_szOfFontAt100Pcnt * newFactor, oldFont.Style, GraphicsUnit.Point);
            oldFont.Dispose();

            int newRowHeight = 0;

            foreach (DataGridViewColumn col in m_dataGridView.Columns)
            {
                if (col is DataGridViewTextBoxColumn || col is FwTextBoxColumn)
                {
                    var textBoxColumn = col as FwTextBoxColumn;
                    if (textBoxColumn != null)
                    {
                        textBoxColumn.SetZoomFactor(newFactor);
                    }

                    var font = col.DefaultCellStyle.Font ?? m_dataGridView.DefaultCellStyle.Font;
                    newRowHeight = Math.Max(font.Height + 4, newRowHeight);
                }
            }

            m_dataGridView.RowHeight = newRowHeight;
            m_dataGridView.Invalidate();
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void ChangeZoomPercent(float oldFactor, float newFactor)
        {
            Font oldFont = m_dataGridView.DefaultCellStyle.Font;

            m_dataGridView.DefaultCellStyle.Font = new Font(oldFont.FontFamily,
                                                            m_szOfFontAt100Pcnt * newFactor, oldFont.Style, GraphicsUnit.Point);

            Font fnt;
            int  newRowHeight = 0;

            foreach (DataGridViewColumn col in m_dataGridView.Columns)
            {
                if (col is FwTextBoxColumn)
                {
                    FwTextBoxColumn fwtbc = col as FwTextBoxColumn;
                    fwtbc.SetZoomFactor(newFactor);

                    using (fnt = new Font(fwtbc.Font.FontFamily,
                                          m_szOfFontAt100Pcnt * newFactor, fwtbc.Font.Style, GraphicsUnit.Point))
                    {
                        newRowHeight = Math.Max(fnt.Height + 4, newRowHeight);
                    }
                }
                else if (col is DataGridViewTextBoxColumn)
                {
                    fnt = (col.DefaultCellStyle.Font ??
                           m_dataGridView.DefaultCellStyle.Font);

                    newRowHeight = Math.Max(fnt.Height + 4, newRowHeight);
                }
            }

            m_dataGridView.RowHeight = newRowHeight;
            m_dataGridView.Invalidate();
        }