Windows Develop Bookmark and Share   
 index > Windows Forms General > displaying custom control in datagridview column
 

displaying custom control in datagridview column

Hi ,

I have a datagridview in which I want to display a user control. I know how to create a custom editing control that will be activated when the user is editing a cell. But I want the control to be displayed even when the user is not editing. Please help me in achieving this.

Thanks,

Vara

Vara  Thursday, September 07, 2006 1:29 PM

You might think of the alternative of overriding the OnCellPaintmethod or handling the CellPaint event of your Custom Datagridviewcell class if that is possible (painting the value in view mode, then in edit mode, your user control will do the rest). However, if this is not possible or if you for some reason find that inconvinient, you will have to make your custom datagridviewcell that hosts the editing control implement theIDataGridViewEditingCell Interface so that it will be able to display the user control even in view mode. Before that see for one of the DataGridViewCell child classes, one of them might be useful to u to derive from instead of writing the code all over again. I had a Smilies field once that stored integers in the database corresponding to different smilies. In the editing mode, i had a custom user control to edit the value (showing a table with available smilies retreived from another table in the database). However, when i quit editing mode in the grid, the integer value is what appears instead of the smily i choose. So i derived my custom DataGridViewCell from DataGridViewImageCell with some modification so that the cell will display the image instead of just a number! For any further questions, feel free to post back here!

Hope this helps!

CSharpFreak  Saturday, September 09, 2006 9:29 AM
Whether both IDataGridViewEditingControl Interface and IDataGridViewEditingCell Interface are to be implemented and if yes
plz explain how is it possible
shinjin  Tuesday, September 11, 2007 2:48 AM

You can use google to search for other answers

Custom Search

More Threads

• How to programatically scroll down the panel to a child control?
• ActiveX control seeks Handle!
• Accesiblename & AccesibleDescription Properties
• Export/Import Data
• Microsoft Outlook 11.0 Object Library
• How to get html code from webBrowser before it get submit to the Server ?
• Login program
• RichTextBox double-click on text doesn't work correctly
• Creating a GetEnumerator method
• EventHandlers for dynamically created controls.