This is a migrated thread and some comments may be shown as answers.

GridView's Child PageViewElement

4 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 18 Jun 2018, 09:48 PM

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
    }
}

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Jun 2018, 10:53 AM
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.
0
Manoj
Top achievements
Rank 1
answered on 19 Jun 2018, 05:18 PM

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

0
Manoj
Top achievements
Rank 1
answered on 19 Jun 2018, 05:44 PM

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;
 
 
}
0
Dimitar
Telerik team
answered on 20 Jun 2018, 08:32 AM
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.
Tags
GridView
Asked by
Manoj
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Manoj
Top achievements
Rank 1
Share this question
or