Hosting control in details view in a DataGridView RRS feed

  • Question

  • I want to have a usercontrol displayed in a datagridview details view which shows when you press that [+] sign but I couldn't figured out how to do it. I'd appreciate any ideas about this.
    Wednesday, November 26, 2008 7:44 PM


All replies

  • Hi armagane,


    I’m not so sure what you want. However, if you just want to host a userControl in the DataGridView. Here is an example How to: Host Controls in Windows Forms DataGridView Cells in MSDN.


    If I’ve misunderstood you, please don’t hesitate to let me know.


    Best regards,

    Bruce Zhou


    Friday, November 28, 2008 3:40 AM
  • Thanks for the link, but it's not what I want. It seems I wasn't clear enough, let me explain.

    Think of a simple master-detail datagrid. First, you see the master grids rows and a plus sign at the beginning of the rows. When you click the plus sign, the master grid expands and you see another grid beneath that row, which is a detail grid. Now what I want to is, display my own usercontrol when you click the plus sign, instead of that detail datagrid.

    Do you think this is possible?
    Friday, November 28, 2008 12:38 PM
  • Hi armagane,


    Yes it is possible. Many people had asked how to show the expandable Rows in the DataGrid before. The old DataGrid control supports this functionality. However, the new DataGridView control doesn’t have built in support about this.


    So you can choose to use DataGrid control for convenience. Or you can choose to use DataGridView with writing a lot of customization code. You can take a look at this blog: Customizing the DataGridView to support expanding/collapsing (ala TreeGridView)


    The following is a relevant question:



    Best regards,

    Bruce Zhou


    Friday, November 28, 2008 3:11 PM
  • That's exactly what I need, thanks a lot Bruce!
    Friday, November 28, 2008 8:59 PM