The SHORT Version:
In a winForm, I'm using the .Text property of a combobox instead of a label. Ex: [pick car make]. The combobox is set to a datasource.
On selecting a line item from a datagridview in the bottom of the form, to edit in the control in the top, I have to set to values for the combobox like this: cboMake.SelectedItem = CarProperty.Make; cboMake.Text = CarProperty.Make;
If I don't set the .Text value, it still displays [pick car make]
Is there a better way to do this?
The LONG Version:
The control setup: I have a combobox set to a datasource. Also, instead of using labels on my winForm, I'm using the .Text property so when the user opens the form, they see a combobox with "[pick the make]" displayed. Think car make/model.
The form setup: the top part of the form is a view/edit/add panel and the botton part of the form is a datagridview displaying all of the different ideas the user has created. For simplicity let's say the form is use to record all makes and models of a car the person has ever owned. The datagridview shows all of these and if they want to see the details behind one (or edit it), they select it from the datagridview and it populates in the top part of the form. All of this code is working...sort of.
The implementation: After the user edits a top value, the edits are saved and the upper controls are cleared and have the .Text properties reset to things like "[pick a make]" so the user can add a new entry if desired.
The problem: When the user picks a line from the datagridview and it populates the controls at the top, some comboboxes display the correct value and some display the "help" text like "[pick the make]".
My solution: On selecting a line item to edit, I have to set to values for the combobox: cboMake.SelectedItem = CarProperty.Make; cboMake.Text = CarProperty.Make;
Is there a better way for me to do this to display the help text and/or set the combobox value when the user selects a line item to edit?
I figure my first option would be to add the "help label" into the datasource and then ignore the .Text property completely. I've done that in the past and so this was the first time I thought I'd try using the .Text property.
Turns out I can assign to .Text and that also sets the selecteditem.