How can I change size of GridDetailViewRowElement/GridDetailViewCellElement?

14 posts, 1 answers
  1. Raymond
    Raymond avatar
    134 posts
    Member since:
    Jul 2010

    Posted 30 Dec 2010 Link to this post

    Hi!

     

    How can I change size of GridDetailViewRowElement/GridDetailViewCellElement?

    Default size is too thick for me.

     

    Regards

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hello Raymond,

    Hope you're well today. Again, this should be a case of using ViewCellFormatting and ViewRowFormatting events. for exmaple
    Private Sub RadGridView1_ViewCellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
        If TypeOf e.CellElement Is GridDetailViewCellElement Then
        End If
    End Sub

    Hope that helps, but let me know if you need more information
    Richard
  3. Raymond
    Raymond avatar
    134 posts
    Member since:
    Jul 2010

    Posted 30 Dec 2010 Link to this post

    Thanks, I am ok J

    I did exactly what you did and I tried to change couple properties:

                  e.CellElement.Size = new Size(2, 2);

                  e.CellElement.HorizontalLineWidth = 2;

     

    but this element of gird still have the same size (too thick).

     

    Regards

     

  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    Hi Ratmond,

    Are you able to post a screenshot somewhere of how you would like it to look, and I will do my best to work it out for you.
    thanks
    Richard
  5. Raymond
    Raymond avatar
    134 posts
    Member since:
    Jul 2010

    Posted 30 Dec 2010 Link to this post

    sure I can send scrennshots
    where I can send it?
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Dec 2010 Link to this post

    At the moment, the facility to add screenshots on the telerik site is down. Do you have just some webspace that you can put it on and add the link in this thread?
    Thanks
    Richard
  7. Raymond
    Raymond avatar
    134 posts
    Member since:
    Jul 2010

    Posted 30 Dec 2010 Link to this post

    I will send link to screenshots when I will come to house (I don`t remember password to my account) – in couple hours.

  8. Answer
    Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 03 Jan 2011 Link to this post

    Hi guys,

    You can change the size of the details cell by setting its Padding property when handling the ViewCellFormatting event:

    void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
    {
        if (e.CellElement is GridDetailViewCellElement)
        {
            e.CellElement.Padding = new Padding(5);
        }
    }

    As to the attachments to forum threads, it should be OK now.

    Let me know if you need anything else.

    Kind regards,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  9. Raymond
    Raymond avatar
    134 posts
    Member since:
    Jul 2010

    Posted 04 Jan 2011 Link to this post

    works perfect

    thanks
  10. Martin
    Martin avatar
    1 posts
    Member since:
    Jan 2011

    Posted 15 Dec 2011 Link to this post

    Hi all,

    the performance is extremly bad if I use the ViewCellFormating event to change the style of the GridDetailViewCellElement. Are there any other way?

    Thanks
    Martin

  11. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 19 Dec 2011 Link to this post

    Hello Martin,

    Thank you for writing.

    I am going to need some more information regarding the scenario causing the observed performance impact. Simply setting the Padding in the ViewCellFormatting event handler should not cause performance impact. However, if you are performing some other time taking operations there, the performance can be reduced, since the event is fired frequently.

    Could you please share with me how to replicate this scenario on my end? Or maybe if possible, please open a new support ticket and attach a sample application. We will investigate this case and we will get back to you with the results.

    Thank you for your time and cooperation.
     
    Kind regards,
    Stefan
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
  12. Martin
    Martin avatar
    1 posts
    Member since:
    Jan 2011

    Posted 20 Dec 2011 Link to this post

    Hi Stefan,

    thanks for your answer. I have a master table with 250 rows and enabled grouping (3 columns). Here I want to change the look of the template table to get a better hierarchy style and want to set another expander picture to get a harmony between the grouping and the template pricture. Further I want to hide the template picture if the template table do not have any rows.
    private void dg_Beats_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
    {
        Telerik.WinControls.UI.GridGroupExpanderCellElement cell = e.CellElement as Telerik.WinControls.UI.GridGroupExpanderCellElement;
         
        if (e.CellElement is Telerik.WinControls.UI.GridDetailViewCellElement)
        {
            Telerik.WinControls.UI.GridDetailViewCellElement temp = e.CellElement as Telerik.WinControls.UI.GridDetailViewCellElement;
            if (temp.BorderColor != System.Drawing.Color.FromArgb(0xD4, 0xE6, 0xFC))
            {
                temp.Padding = new Padding(40, 0, 0, 5);
                temp.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
                temp.BorderColor = System.Drawing.Color.FromArgb(0xD4, 0xE6, 0xFC);
                temp.BackColor = System.Drawing.Color.FromArgb(0xD4, 0xE6, 0xFC);
                temp.BackColor2 = System.Drawing.Color.FromArgb(0xD4, 0xE6, 0xFC);
                temp.BackColor3 = System.Drawing.Color.White;
                temp.BackColor4 = System.Drawing.Color.White;
            }
        }
         
        if (cell != null && e.CellElement.RowElement is Telerik.WinControls.UI.GridDataRowElement)
        {
            if (cell.RowInfo.ChildRows != null && cell.RowInfo.ChildRows.Count > 0)
            {
                if (cell.RowInfo.IsExpanded == true)
                    cell.Expander.SignImage = global::Gina.Properties.Resources.GroupCollapse;
                else
                    cell.Expander.SignImage = global::Gina.Properties.Resources.GroupExpand;
                cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible;
            }
            else
                cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
        }
    }

    If I use the expand all function and start scrolling in the list, the performance is not very well.

    Thanks
    Martin
  13. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 23 Dec 2011 Link to this post

    Hi Martin,

    Thank you for the further explanation and the sample code.

    I have created a sample application according to your description, and in it I have used your code to test the performance. However, performance was not hurt on my end. Please refer to the attached application and give it a try. If you continue experiencing this issue, I would like to kindly ask you to open a new support ticket, and there attach your application, together with detailed description regarding how to reproduce the undesired behavior. We will investigate your application and the we will be able to provide you with further support.

    Greetings,
    Stefan
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
  14. Ebrahim
    Ebrahim avatar
    4 posts
    Member since:
    Nov 2011

    Posted 27 Dec 2011 Link to this post

    Hi Martin,

    This will solve your problem.

    private void radGridView_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
    {
      e.Cancel = !IsExpandable(e.ParentRow);
    }
     
     
    private bool IsExpandable(GridViewRowInfo rowInfo)
    {
      GridViewHierarchyRowInfo hRowInfo = rowInfo as GridViewHierarchyRowInfo;
      if (hRowInfo == null) return false;
     
      if (hRowInfo.ChildRow != null && hRowInfo.ChildRow.ChildViewInfos.Count > 0)
      {
        return hRowInfo.ChildRow.ChildViewInfos.Any(info => info.ChildRows.Count > 0);
      }
     
      return false;
    }

    I got this code from one of the telerik admin.
    Try it.
Back to Top