add my own user control in a column

8 posts, 0 answers
  1. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 17 Oct 2011 Link to this post

    Hello,
    can I add my own user control in a column?
    (RadGridView)
    If so, can you show me an example?

    Thanks
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 20 Oct 2011 Link to this post

    Hello Axel,

    Yes, you can add custom controls in a grid cell. However, we recommend using elements instead. Using controls may lead to performance loss and high memory consumption. In addition, you will experience visual glitches because controls cannot be clipped inside other controls efficiently in WinForms.  That is why our suite actively uses elements just like in WPF or Silverlight. This allows us also to support themes and animations. 

    You can consider the following KB article which describes how to add radio button elements to a grid cell. Please describe in detail the desired look and behavior that you want to achieve and we will be glad to assist you further.

    I am looking forward to your reply.
     
    Kind regards,
    Jack
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  3. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 24 Oct 2011 Link to this post

    Hello,
    I have attached a picture of my UserControl.
    This is to be inserted into a cell.
    It will display dates in different colors. Furthermore, it has other futures.

    When I look at the example radio button look at her.
    Then there is a problem with "this.Children.Add (gridstatus)"
    Gridstatus is a UserControl and not a RadElements

    What can I do

    Am thankful for every tip

    addition:
    I want to fill the UserControl "grid status" with a DataTable.
    The DataTable I want to save again in a DataTable which I will bind to the grid.

  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 24 Oct 2011 Link to this post

    Hello Axel,

    Thank you for writing me back and thank you for these details.

    Like I said in my previous post, it is not recommended to use user controls in grid cells. That is why I pointed you to the radio button example. You could use elements to display custom data instead of a user control. This way your application will be faster and will look better. Another option will be to override the cell painting mechanism. Please take a look at the GridView >> Customize >> Custom Painting example in our demo application. It describes a similar scenario. 

    I am not sure about the binding question, could you please describe it in detail?

    Best wishes,
    Jack
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  5. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 25 Oct 2011 Link to this post

    Hello,

    you said
    that it is not performing well enough to insert a UserControl. Can you show me an example anyway.

    I've been looking at the example "GridView>> Customize>> Custom Painting." But that's not right for me.

    Binding to Data:
    I want to bind the grid to a DataTable.
    A column of the DataTable is a DataTable as the Type.
    And I would like to use this column to fill my UserControls.

    That's the plan.
  6. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 28 Oct 2011 Link to this post

    Hi Axel,

    Thank you for writing us back.

    Your scenario seems to be similar to one of the hierarchy examples in our demo application. Could you please describe it with greater detail? I will be glad to help further.

    The following sample demonstrates how to add a button control in a grid cell. You should replace the button with your custom control:
    public class ButtonColumn : GridViewDataColumn
    {
        public ButtonColumn(string fieldName)
            : base("ButtonColumn", fieldName)
        {
            Width = 100;
        }
     
        public override Type GetCellType(GridViewRowInfo row)
        {
            if (row is GridViewDataRowInfo)
            {
                return typeof(CustomCell);
            }
            return base.GetCellType(row);
        }
    }
     
    public class CustomCell : GridDataCellElement
    {
        RadHostItem hostItem;
        RadButton button;
     
        public CustomCell(GridViewColumn column, GridRowElement row)
            : base(column, row)
        {}
     
        protected override void CreateChildElements()
        {
            button = new RadButton();
            button.Text = "Click me!";
            hostItem = new RadHostItem(button);
            this.Children.Add(hostItem);
        }
     
        public override bool IsCompatible(GridViewColumn data, object context)
        {
            return data.Name == "ButtonColumn" && context is GridDataRowElement;
        }
    }

    I hope this helps.
     
    Best wishes,
    Jack
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  7. Bao
    Bao avatar
    54 posts
    Member since:
    Jan 2015

    Posted 19 Sep 2017 in reply to Jack Link to this post

    Hi Jack,

    I have custom textbox when i do this way , it has problem with tabbing.

    https://www.screencast.com/t/jO84luQcpt2

  8. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3530 posts

    Posted 20 Sep 2017 Link to this post

    Hello, Bao, 

    Thank you for writing.  

    Feel free to submit a support ticket where you can provide a sample project demonstrating the exact problem that you are facing. This would be appropriate way Telerik support to investigate the precise case and assist you further. 

    Thank you for your understanding and cooperation.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 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