Managed C++: Build a Custom NumericUpDown Cell and Column for the DataGridView Control

Managed C++: Build a Custom NumericUpDown Cell and Column for the DataGridView Control

I'm trying to follow the instructions from this MSDN article to create my own DataGridViewNumericUpDown cells and columns. The only problem is this: I'm using Managed C++!!! Not C#!!!

So far, I've successfully created a class that inherits from DataGridViewTextBoxCell. Then the article says I need to create a new DataGridViewNumericUpDownEditingControl class, which inherits from the classes NumericUpDown and IDataGridViewEditingControl. So I did that, but I get the errors:

error C3766: 'namespace::DataGridViewNumericUpDownEditingControl' must provide an implementation for the interface method 'System::Windows::Forms::DataGridView ^System::Windows::Forms::IDataGridViewEditingControl::EditingControlDataGridView::get(void)'error C3766: 'namespace::DataGridViewNumericUpDownEditingControl' must provide an implementation for the interface method 'void System::Windows::Forms::IDataGridViewEditingControl::EditingControlDataGridView::set(System::Windows::Forms::DataGridView ^)'These errors replicate for all the get() and set() methods of the interface's properties. But how do I write get() and set() methods in C++? And is that really necessary after all? The MSDN example I cited above doesn't even show how it's done in C#.

I tried this, but then I got an error telling me that I must use the keyword "__property" instead of "property". So I tried that as well, but then the compiler told me I had to change the /clr option and that's simply out of the question for me. Patience ran out and I decided to post the question.

Any ideas?
You have to implement the members of the interface. Here are two properties and a function:

       virtual property DataGridView^ EditingControlDataGridView

       {              DataGridView^ get () { return Parent;}

              void set (DataGridView^ value) { Parent = value; }

       }
       virtual property Object^ EditingControlFormattedValue

       {              Object^ get () { return Value; }

              void set (Object^ value) { Value = (int)value;}

       }
       virtual void ApplyCellStyleToEditingControl( DataGridViewCellStyle^ dataGridViewCellStyle) override

       {              // . . .

       }Do this for the other members of IDataGridViewEditingControl, described in documentation.

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright