Your custom control only displays when you edit the cell. While in non-editing mode DataGridView itself renders the data. However as you have already derived a class from DataGridViewTextBoxCell, therefore you can customize the display by overriding the Paint method in the same class.
I mean you need to modify your custom "cell" class which you have most probably derived from DataGridViewTextBoxCell. In this class you can override its Paint method to render the data as you like. Long ago I created a custom DataGridView Progress Bar column which does NOT support editing but does custom painting. You can look into the code to have a better idea. http://arsalantamiz.blogspot.com/2008/04/datagridview-custom-percentage-column.html I guess "Group Moderator" wont mind as the link is related to the topic :) On Wed, Sep 8, 2010 at 3:42 AM, R <[email protected]> wrote: > I am not sure what to do in the in cell painting event. I have looked > at the example given in msdn site and had implemented this example > with my custom control. When I look at the datagrid, I do not see my > control instead I see string[].Array. When I click on the cell and go > into edit mode, I can see and edit my control. > How can I modify the code so that by default, the data is displayed in > my user control. Thank you. > > On Sep 3, 11:24 pm, Arsalan Tamiz <[email protected]> wrote: > > Normally the rendering of a "Cell" in DataGridView control > > is handled through CellPainting event. If your goal is to just change the > > look of a cell then this is simple. You just have to use the CellPainting > > event. > > > > But here as I can see you need custom editing too. For this purpose you > need > > to host your own control in DataGridView Cell. > > > > Here is a msdn article< > http://msdn.microsoft.com/en-us/library/7tas5c80(v=VS.90).aspx>which > > describes how to host DateTimePicker control in DataGridView cell. > > This will give you a quick start. > > > > > > > > On Sat, Sep 4, 2010 at 3:42 AM, R <[email protected]> wrote: > > > Template column is in gridview in ASP.NET not in datagridview in > > > windows forms. > > > > > On Sep 3, 2:52 pm, Jamie Fraser <[email protected]> wrote: > > > > TemplateColumn > > > > > > On Fri, Sep 3, 2010 at 9:23 PM, R <[email protected]> wrote: > > > > > How can I create a custom column in datagridview that displays data > in > > > > > a user control? > > > > > In the datagridview I have to show the Goal value and it > corresponding > > > > > Achieved value for each year. > > > > > > > ex: > > > > > | 2010 | 2011 | 2012 > > > > > ====================================== > > > > > Earnings | T | $20000 | $25000 | $30000 > > > > > | A | $18000 | $26000 | $29000 > > > > > > --------------------------------------------------------------------------- > > > > > Expenses | T | $10000 | $10000 | $10000 > > > > > | A | $9000 | $10000 | $12000 > > > > > > --------------------------------------------------------------------------- > > > > > New Hire | T | 20 | 10 | 6 > > > > > | A | 22 | 10 | 5 > > > > > > > So I need two textboxes showing in the cell at the same time (both > > > > > when the cell is in the display mode and when it is in Editing > mode) > > > > > > > Can this be achieved? Any other ideas are more than welcome. > > > > > > > Thank you.- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -
