Example for deriving from datagridviewcell

I designed a user control that can be described as an enhanced combobox. It has more than just a dropdown button right besides the text field and offers much more functionalty. Because deriving from a combobox isn't very flexible it's derived from a user control and contains a textbox and some buttons on the right.

It looks like this:

[ Textbox ][But1][But2][But3]

Now I want to integrate this control in a datagrid. I already found out how to use it as the editing control for a datagridviewcell. But because the functionalty that is offered by the different buttons of the control has to be also accessible in non-editmode, I need to create my own datagridviewcell.

Can I inherit from a datagridviewtextboxcell and add my buttons on the right side somehow?

Otherwise I would like to see an example how to create your own datagridviewcell.

Thank you!
David

[880 byte] By [TAS] at [2008-2-18]
# 1
You can override the paint method of DataGridViewTextBoxCell to display your buttons. You will need to handle clicks yourself if clicks are meant for anything other than entering edit mode.

I am working on a sample in which I derive from DataGridViewCell. Let me know if you come up with anything in the meantime.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 2
Could you please give me a starting point what I've to do to get a button by overriding the paint method?

Do I have to manually draw a button, draw it's image, etc. ?

Or can I create a new instance from a button and place it in the textbox?

What is the best way to handle the click?

Thanks a lot!

TAS at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 3
Hi David,

Did you find the way to derive from datagridviewcell? Could you send me some code to show how to do? Actually I'm trying to do exactly the same as you: I've created my own combo box (which displays a resizable TreeView), and I would like to use it in my datagridview.

Many thanks in advance.

Chris
ch_cu2 (@) yahoo [.] fr

ch_cu at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...