DataGridViewComboBox

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have bound a dgvcombobox to a datasource/table/column value set. I would
like to be able to include a NULL value in the pick list the combo box
shows, but it seems that once I've clicked in the combo box, there's no way
to assign a NULL value in the DataGridView for that column.
 
John said:
I have bound a dgvcombobox to a datasource/table/column value set. I would
like to be able to include a NULL value in the pick list the combo box
shows, but it seems that once I've clicked in the combo box, there's no way
to assign a NULL value in the DataGridView for that column.

Why don't you insert the Null to the datasource/table/column before
binding it?

Chris
 
Hello John,

Set combobox.Text="".

J> I have bound a dgvcombobox to a datasource/table/column value set. I
J> would like to be able to include a NULL value in the pick list the
J> combo box shows, but it seems that once I've clicked in the combo
J> box, there's no way to assign a NULL value in the DataGridView for
J> that column.
J>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Michael said:
Hello John,

Set combobox.Text="".

J> I have bound a dgvcombobox to a datasource/table/column value set. I
J> would like to be able to include a NULL value in the pick list the
J> combo box shows, but it seems that once I've clicked in the combo
J> box, there's no way to assign a NULL value in the DataGridView for
J> that column.
J> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Don't think that solves the issue:

"I would like to be able to include a NULL value in the pick list the"
 
If you populate the datasource with a select, you can insert the Null value
using an union. For example

SELECT
null AS CustomerID,
'(none)' AS CustumerName
FROM
Customers
UNION
SELECT
CustomerID,
CustomerName
FROM
Customers;
 
Chris said:
Why don't you insert the Null to the datasource/table/column before
binding it?

I'll give it a try. I was just hoping there was a "AllowNull" setting on the
control that would allow it to work without me having to do that :)
 
Alex Bibiano said:
If you populate the datasource with a select, you can insert the Null
value using an union. For example

SELECT
null AS CustomerID,
'(none)' AS CustumerName
FROM
Customers
UNION
SELECT
CustomerID,
CustomerName
FROM
Customers;


This works nicely, thanks.
 

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

Back
Top