الخميس، 11 يونيو 2015

Remove BorderBox,TextAlignment and ForeColor - radGridView1_CellFormatting Event

private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            try
            {
                if (e.CellElement != null && e.RowIndex > -1)
                {
                    //remove border box
                    var style = new BorderBoxStyle();
                    e.CellElement.BorderBoxStyle = style;
                    e.CellElement.BorderWidth = 0;

                    if (e.Column.Name == "UserName")
                    {
                        e.CellElement.Font = new Font("Arial", 8, FontStyle.Bold);
                        if (Convert.ToInt32(e.Row.Cells["UserId"].Value) == MyParameters.userProfile.UserId)
                            e.CellElement.ForeColor = Color.DodgerBlue;
                        else
                        {
                            e.CellElement.ForeColor = Color.Black;
                        }
                        e.CellElement.TextAlignment = ContentAlignment.TopLeft;
                    }
                    else
                        e.CellElement.ForeColor = Color.Black;
                }
            }
            catch (Exception ex)
            {
                RadMessageBox.Show(MyMethods.ExceptionDetails(ex), "Exception", MessageBoxButtons.OK,
                    RadMessageIcon.Error);
            }
        }

ليست هناك تعليقات:

إرسال تعليق