GridView's Child PageViewElement

5 posts, 0 answers
  1. Manoj
    Manoj avatar
    5 posts
    Member since:
    Jun 2018

    Posted 18 Jun 2018 Link to this post

    I need to change the BackColor of the Tabs inside the PageViewElement of a Child row in a Gridview. I can access the PageViewElement itself, but how do I get to the Tabs' BackColor Property?

     

    private void myDataTable_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
        if (detailCell != null)
        {                              
            detailCell.Margin = new Padding(60, 0, 0, 0);
            detailCell.Font = new Font(new FontFamily("Calibri"), 20.0f, FontStyle.Bold | FontStyle.Underline);
            detailCell.ForeColor = Color.FromArgb(255, 102, 0);
     
            detailCell.PageViewElement.DrawFill = true;
            detailCell.PageViewElement.BackColor = Color.Red; //this sets the backcolor of the PageViewElement
        }
    }
  2. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 19 Jun 2018 Link to this post

    Hello Manoj,

    You can use the following code to access the items and set the back color:
    private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
        if (detailCell != null)
        {
            detailCell.Margin = new Padding(60, 0, 0, 0);
            detailCell.Font = new Font(new FontFamily("Calibri"), 20.0f, FontStyle.Bold | FontStyle.Underline);
            detailCell.ForeColor = Color.FromArgb(255, 102, 0);
     
            detailCell.PageViewElement.DrawFill = true;
            foreach (var item in detailCell.PageViewElement.Items)
            {
                item.BackColor = Color.Red;
                item.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
                item.DrawFill = true;
            }
     
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Manoj
    Manoj avatar
    5 posts
    Member since:
    Jun 2018

    Posted 19 Jun 2018 Link to this post

    Hi Dimitar.

    That's works.Thanks buddy.

    Now I have another question. How do I set the ItemFitMode for these tabs? VisualStudio2012Dark theme I am applying just washes out all the borders and colors. Now that I can set the back color, and If I can set the ItemFitMode to StripViewItemFitMode.Fill and adjust Borders to make the tabs visible, Ill be happy and stop bugging you guys.

    MG

  4. Manoj
    Manoj avatar
    5 posts
    Member since:
    Jun 2018

    Posted 19 Jun 2018 in reply to Manoj Link to this post

    ok, got the Border figured out. 

    Now only need the StripViewFitMode

    foreach (var item in detailCell.PageViewElement.Items)
    {
        item.Size = new System.Drawing.Size(500, item.Size.Height);
        item.BackColor = Color.FromArgb(64,64,64);
        item.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        item.DrawFill = true;
     
        item.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
        item.BorderColor = Color.FromArgb(255, 102, 0);
        item.BorderGradientStyle= Telerik.WinControls.GradientStyles.Solid;
        item.BorderWidth = 3;
        item.DrawBorder = true;
     
     
    }
  5. Dimitar
    Admin
    Dimitar avatar
    2960 posts

    Posted 20 Jun 2018 Link to this post

    Hello Manoj,

    You need to cast the ViewElement to the appropriate type. Here is the code:
    var stripElement = detailCell.PageViewElement as RadPageViewStripElement;
    stripElement.ItemFitMode = StripViewItemFitMode.Fill;

    Let me know if I can assist you further.
     
    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top