VS2005 C# DataGridView Editable Control question

  • Thread starter The angry snapping Goose
  • Start date
T

The angry snapping Goose

Hi All:

I wish I brought my code sample home with me but I'm afraid I left it at
work. I'm struggling with trying to attach an "Editable" control to a
"bounded" DataGridView "after" the grid has been bounded.

Going from memory, I have a Typed Dataset which has a DataTable. This
datatable has a "Datetime" column in it. I am NOT creating the
DataGridTableColumns myself. Rather, they're being created at the time I
say:

dataBindingSource.DataSource = myDataTable;

Well... I located an example on how one can have a DatetimePicker for a
Column when you choose to edit the column. Since one of the columns will be
a Date, this control would be perfect. The example, however, assumes you
will create the DataGridView and all of it's DataGridViewColumns by hand.
In the constructor, it creates all of it's columns up front and then fills
in the DataTable afterwards. It does not use a binding source. So this
example won't work. I've tried numerous things to try and replace the
Date's default editor (which is a TextBox) for that column "after" the
bindingSources' dataSource has been set but no luck.

I'm familiar with Java Swing (I'm coverting to WinForms) and Java has the
getTableCellEditorComponent() method that you can override which allows you
to return an Editor of your choice when the user clicks in a cell to start
editing.

Is there a property or something similar to this in WinForms using the
DataGridView??? I'd like to return an instance of a CalendarPicker()
control which causes the datechooser dialog to come up. I have no choice
though to use the bindingSource so I cannot manually create the
DataGridViewColumns()...

thanks again...
 
E

Eric Smith

Do you know what columns you'll have in advance? You can still use
databinding for the data but manually set up the columns to use the types
you want. I've done this for something similar to what you're describing --
I added a custom date/time column for date/time data values.

But if you don't know what columns you'll have in advance then someone with
more experience than me will have to give you advice.

--Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top