none
How to create completly new DataGridViewCell RRS feed

  • Question

  • I want to create a new Custom DataGridViewCell/Column.

    There a many examples which inherits from the given Controls (DataGridViewTextBoxColumn,DataGridViewTextBoxCell,..), but this is not what i need.

     I want to show some informations (text/picture) on this new Control, i think a panel with labels is good for this.

    The values had not been saved from this control this is only for display.

    I don't no where to start.

    Sorry for my bad english

    phil

    Thursday, March 30, 2006 10:45 AM

Answers

  • Hi, you want to show text and image in the same datagridviewcell, don't you?

    Actrully, the DataGridView control does not have any built-in support for showing an icon and text in the same cell. Through the different painting customization events, such as the CellPaint event, you can easily display an icon next to the text in the cell.There is an example extends the DataGridViewTextColumn and cell to paint an image next to the text. The sample uses the DataGridViewCellStyle.Padding property to adjust the text location and overrides the Paint method to paint an icon. This sample can be simplified by handling the CellPainting event and performing similar code.

     

    http://www.windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc

    If you have any further questions, feel free to let me know.

     

    Best Regards

     

    Gavin

     

     

     

    Monday, October 29, 2007 2:03 AM

All replies

  • To much edges in my brain.

    Just only derive from DataGridViewTextBoxColumn, override the paint method.

    In the paint painting strings ,circles and so on...

    The editing control is another story ...

    cu

    phil

    Tuesday, April 18, 2006 3:00 PM
  • I try to make the same control on a datagridViewCell.

    Have you found a solution ?

    Regards,
    Sylvain
    Monday, October 22, 2007 1:09 PM
  • Hi, you want to show text and image in the same datagridviewcell, don't you?

    Actrully, the DataGridView control does not have any built-in support for showing an icon and text in the same cell. Through the different painting customization events, such as the CellPaint event, you can easily display an icon next to the text in the cell.There is an example extends the DataGridViewTextColumn and cell to paint an image next to the text. The sample uses the DataGridViewCellStyle.Padding property to adjust the text location and overrides the Paint method to paint an icon. This sample can be simplified by handling the CellPainting event and performing similar code.

     

    http://www.windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc

    If you have any further questions, feel free to let me know.

     

    Best Regards

     

    Gavin

     

     

     

    Monday, October 29, 2007 2:03 AM
  • Thanks a lot,

     

    But in fact I need to have more than one textbox or label in my cell. I try to create a small panel with 3 or 4 labels and a picture to have a list in wich I can describe in each cell a company with his picture, his name, the contact name and the contact phone number. For this It seems me that  just modify the cellPainting event don't allow me to do this.

     

    Actually I try to add controls (a panel) in my cell but I have some problems to refresh all the Cells panel when I scroll my List.

     

    Have you see a exemple in wich we can create a panel in a cell and use it in a datagridView ?

     

    Best Regards.

    Sylvain
    Wednesday, October 31, 2007 3:41 PM