It seems I cannot get away without having button specs on the new columns. So I’ve added a ButtonSpecs collection to the column class of each of the following types…

  • DateTimePicker
  • MaskedTextBox
  • NumericUpDown
  • DomainUpDown
  • ComboBox

Here you can see a couple of example images…

To make life a little easier for the developer I have added a ButtonSpecClick event onto the columns that is fired whenever any button spec is clicked for any cell in that column. This event has parameters that made it easy to get hold of the column, cell and button spec instances involved in that click. Stops you needing to walk around the data structures finding your way from the button spec to the cell and then the column, which although not hard is certainly a pain to work out each time you need to do it.

Note that there are no button specs on the already defined Krypton columns  TextBox/CheckBox/Button/Link. This is because they work in a different way that makes it impractical to add them. All the new columns have an instance of an actual control that is used when editing the cell. So when you click on a numeric column it uses a KryptonNumericUpDown instance perform the drawing and editing. As the KryptonNumericUpDown already has support for button specs this makes it possible to add that capability by moving the button specs from the column collection into the control for the duration of editing. But the TextBox/CheckBox/Button/Link columns all perform drawing by using direct calls to the renderer and adding extra code to simulate the presence of buttons is not a pleasant thought.

11 Responses to “DataGridView ButtonSpecs”

  1. Waescher Says:

    This is really great! I’m really looking forward to this update.

  2. vesuvius Says:

    That is looking like one sweek DataGrid. Of the older columns, I don’t think you’d wand to use a button spec with a CheckBox/Button/Link, only the textbox.

  3. dg78 Says:

    Very good news : there are now ButtonsSpecs on useful controls.
    Bad new : the TextBox is not inside these controls.

    I think that one day, due on demand, you need to add it. I hope this day will not be too far.

    For CheckBox/Button/Link columns, it is not useful.

    Many Thanks

  4. Waescher Says:

    Maybe you can use a new control with buttonspecs instead of the Textbox-Column – what about the MaskedTextBox without a mask?

  5. dg78 Says:

    @ Waescher,

    I didn’t think about a MaskedTextBox without a mask. I think it is the solution.

    Thanks.

  6. Waescher Says:

    You’re welcome ;)

  7. Phil Wright Says:

    I have just updated the text box column to use the KryptonTextBox instead of just drawing the text using the rendered. So now it has button specs as well!

  8. Waescher Says:

    So this approach is now obsolete ;)

  9. dg78 Says:

    No, no, it is not obsolete .. it is fine ;))
    Sooner or later, it is necessary and it is better sooner than later.
    Thanks Phil

  10. Waescher Says:

    No, the “MaskedTextBox without mask”-approach is obsolete …

  11. Raul Says:

    Wow it´s great!!! but for me ButtonSpec doesn´t appear anytime. I added a new column of type Krypton and added their buttonspecs to the column. I can´t see the buttonspec in KryptonDataGridView.

    Thanks for all!

Leave a Reply