If I want to have 2 fields in the ValueMember property
instead just 1, how can I do ?
See, I have a primary key that the user can enter himself
(it is a Municipality static number and it is not suppose
to change often... like 1 time in 5 years). My second
field in the primary key is a counter. When I show the
available Municipality in the ComboBox, I want to show
only the last one (so I want the MAX
(ID_Municipality_Version)). Your solution help me to show
2 fields at the same time in the ComboBox. But on my
side, I want to do DataBinding so the right Minicipality
is displayed for a specific Mayor. (That was my initial
question).
If you are able to answer it, maybe could you help me to
find a way to hide the Municipality that I wont need when
I create a new Mayor (that mean I want to select only the
MAX(ID_Municipality_Version)). It is a complex problem
for me because I don't understand all the ADO.NET and
database concepts.
Thank you for your help.
-----Original Message-----
Use an Expression Column, set that as the DisplayMember and set whatever the
'value' field is as the valuemember.(Remember, it's displaymember)
MyDataTables.Columns.Add("SomeColumnName", typeof string);
MyDataTables.Columns["SomeColumnName"].Expression = "FirstField + ' ' +
SecondField";
myComboBox.DisplayMember = "SomeColumnName";
myComboBox.ValueMember =
"FirstFieldOrWhateverFieldYouWantSelectedValueToBe";
Sébastien said:
Hi, I would like my ComboBox to use a composed primary
key as ValueMember property (cause there is no DataMember
property).
--A composed primary key is composed of 2 or more fields
to identify unique records.--
I did not find any way to make it possible. The DataGrid
work perfectly with composed primary keys because it have
a DataMember property and the value can be a Relation
name instead a field name.
If someone could help me, I would appreciate.
.