List Info

Thread: C-Sharp (C#) Group: DataGridViewComboBoxColumn and Formatting | Parsing




C-Sharp (C#) Group: DataGridViewComboBoxColumn and Formatting | Parsing
user name
2006-03-23 19:35:12
I'm using the new v2.0 DataGridView object to handle
formatting int
values from a DataRow into items in a hash table.

(e.g. keys {0, 1,...n} values {
"hash0,"hash1",..."hashn"})

I am subscribing to the DataGridView.CellFormating and
DataGridView.CellParsing
events. I am able to successfully format and parse values
back using
the
standard DataGridViewTextBoxColumn

Now, I am overriding the AutoGenerateColumns property of the
view and
creating DataGridViewComboBoxColumn, I wish to have a
dropdown with
the enumerated values data
{"hash0","hash1"..."hashn&quo
t;}

I note that when the Items property of the Column is set to

new object[] { "hash0",
"hash1",..."hashn"}

I get a DataError event as the unformatted original values
{0,1,...n}
are checked against the objects in the Items array without
calling any
user formatting hooks
first.

So I change the Items property to

new object[] {0,1,...n}

And the DataError goes away, however I do not see the
DataGridView.CellFormatting
hook being called upon expansion of the combo box (clicking
the down
arrow).

So the values in the listbox portion of the combo box
control are
displayed as {0,1,...n}

Are there any more user formatting hooks, that one can use
to format
values in the ComboBoxColumn?

Thanks,

- Eric


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: DataGridViewComboBoxColumn and Formatting | Parsing
user name
2006-03-23 22:36:46
Ended up being simpler than I'd expected.

Use

DataGridViewComboBoxColumn.DataSource

pointing to a DS that has both formatted and
unformatted values

and

DataGridViewComboBoxColumn.ValueMember
DataGridViewComboBoxColumn.DisplayMember

to point to the unformatted and formatted values,
respectively.

- Eric


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )