示例#1
0
        private void m_grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            DataGridViewColumn col = m_grid.Columns[e.ColumnIndex];

            e.CellStyle = m_grid.DefaultCellStyle.Clone() as DataGridViewCellStyle;
            CParametreVisuChampTableauCroise parametre = null;

            if (e.RowIndex < m_table.Rows.Count)
            {
                DataRow row = (m_grid.DataSource as DataView)[e.RowIndex].Row;
                if (m_dicColToParametreCol.TryGetValue(col.DataPropertyName, out parametre))
                {
                    if (parametre.ChampFinal is CChampFinalDeTableauCroiseDonnee)
                    {
                        e.Value = parametre.GetValeurData(e.Value, m_parametre);
                    }

                    CFormatChampTableauCroise format = parametre.FormatParDefaut;
                    if (parametre.FormatParDefaut.IsDynamic)
                    {
                        CFormatChampTableauCroise formatDyn = parametre.GetFormatData(row[e.ColumnIndex], m_parametre);
                        if (formatDyn != null)
                        {
                            format = formatDyn;
                        }
                    }
                    CompleteFormatCellule(format, e.CellStyle);
                }
            }
        }
示例#2
0
        public void Init(
            CFormatChampTableauCroise format,
            CElementAVariablesDynamiques eltAVariables,
            bool bForHeader)
        {
            m_elementAVariables = eltAVariables;
            m_format            = format;
            if (format.FontSize == 0)
            {
                m_txtFontSize.IntValue = null;
            }
            else
            {
                m_txtFontSize.IntValue = format.FontSize;
            }
            m_txtColumnWidth.IntValue     = format.Width;
            m_chkBackColor.Checked        = format.BackColor.A != 0;
            m_chkForeColor.Checked        = format.ForeColor.A != 0;
            m_chkSelectedColor.Checked    = format.SelectionBackcolor.A != 0;
            m_colorBack.SelectedColor     = format.BackColor;
            m_colorFore.SelectedColor     = format.ForeColor;
            m_colorSelected.SelectedColor = format.SelectionBackcolor;
            m_colorFore.Visible           = m_chkForeColor.Checked;
            m_colorBack.Visible           = m_chkBackColor.Checked;
            m_colorSelected.Visible       = m_chkSelectedColor.Checked;
            m_cmbFont.Text = format.FontName;
            if (format.Bold != null)
            {
                m_chkBold.Checked = format.Bold.Value;
            }
            else
            {
                m_chkBold.CheckState = CheckState.Indeterminate;
            }

            m_cmbTextAlign.Items.Clear();
            m_cmbTextAlign.Items.Add("");
            foreach (C2iWndTextBox.TypeAlignement align in Enum.GetValues(typeof(C2iWndTextBox.TypeAlignement)))
            {
                m_cmbTextAlign.Items.Add(align);
            }
            if (format.Alignement != null)
            {
                m_cmbTextAlign.SelectedItem = format.Alignement;
            }
            else
            {
                m_cmbTextAlign.SelectedItem = "";
            }
            m_btnFormuleBack.Visible             =
                m_btnFormuleFore.Visible         =
                    m_btnFormuleBold.Visible     =
                        m_btnFormuleSize.Visible = m_elementAVariables != null;
            m_panelWidth.Visible = bForHeader;
            UpdateBoutonsFormules();
        }
示例#3
0
        private void CompleteFormatCellule(CFormatChampTableauCroise format,
                                           DataGridViewCellStyle style)
        {
            bool bChangeFont = format.FontName != "" || format.FontSize != 0 || format.Bold != null;

            if (bChangeFont)
            {
                string strFontName = "Arial";
                float  fSize       = 8;
                bool   bBold       = false;
                if (style.Font != null)
                {
                    strFontName = style.Font.FontFamily.Name;
                    fSize       = style.Font.Size;
                    bBold       = style.Font.Bold;
                }
                if (format.FontName != "")
                {
                    strFontName = format.FontName;
                }
                if (format.FontSize != 0)
                {
                    fSize = format.FontSize;
                }
                if (format.Bold != null)
                {
                    bBold = format.Bold.Value;
                }
                style.Font = new Font(strFontName, fSize, bBold?FontStyle.Bold:FontStyle.Regular);
            }
            if (format.ForeColor.A != 0)
            {
                style.ForeColor = format.ForeColor;
            }
            if (format.BackColor.A != 0)
            {
                style.BackColor = format.BackColor;
            }
            if (format.SelectionBackcolor.A == 0)
            {
                if (m_parametre.FormatRows.SelectionBackcolor.A == 0)
                {
                    style.SelectionBackColor = style.ForeColor;
                    style.SelectionForeColor = style.BackColor;
                }
            }
            else
            {
                style.SelectionBackColor = format.SelectionBackcolor;
                style.SelectionForeColor = style.ForeColor;
            }
            if (format.Alignement != null)
            {
                switch (format.Alignement.Value)
                {
                case C2iWndTextBox.TypeAlignement.Centre:
                    style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    break;

                case C2iWndTextBox.TypeAlignement.Droite:
                    style.Alignment = DataGridViewContentAlignment.MiddleRight;
                    break;

                case C2iWndTextBox.TypeAlignement.Gauche:
                    style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                    break;

                default:
                    break;
                }
            }
        }