I have an Ultragrid that contains a column called "Current Location". This column's EditorControl property is set to my UltraCombo, called "comboSiteLkup". The comboSiteLkup ultracombo has DisplayMember = site code and ValueMember = site id. I am also using a RowEditTemplate with this grid. The Current Location field (type: UltraGridCellProxy) on the RowEditTemplate has a name prefixed with "ugcp" (called "ugcpsite_id_current"). When the RowEditTemplate opens, I can see the ultracombo associated with my Current Location field (good). My problem is - after a user selects a value from the ultracombo, how do I retrieve the VALUE associated with what was selected, not the DISPLAYVALUE? Here's a code snippet of what I'm trying to do: //This is the code-behind the OK button on the RowEditTemplateprivate void btnTemplateOk1_Click(object sender, EventArgs e){ //Using the .Text property here is ok. I want to evaluate the displayvalue. if (ugcpsite_id_current.Text == "CHK" && ugcpCHECKED_OUT_TO2.Text == "") { MessageBox.Show("You must select a person in Checked out to:"); ugcpCHECKED_OUT_TO2.Focus(); } else { //Add BOX if (this.ultraGridRowEditTemplate2.Row.IsAddRow) { // I need the ValueMember here to insert the "site id" into the Box record. I don't know how to retrieve this in code? bOXTableAdapter.InsertBox(ugcpBOX_TYPE.Text, "VERIFIED", ugcpsite_id_current.Text, ugcpSITE_ID_HOME.Text, ugcpJD_BOX_ID.Text, ugcpDESCRIPTION1.Text, ugcpVENDOR_BOX_ID.Text, ugcpCHECKED_OUT_TO2.Text); this.rMSDataSet.BOX.AcceptChanges(); rMSDataSet.BOX_LKUP.Rows.Add(ultraGrid1.ActiveRow); }In the code-behind, I've tried to use syntax like "ugcpsite_id_current.value", but value is not found by Intellisense (not right context).Help?
string displaymember = (string)this.ultraGridRowEditTemplate1.Row.Cells[this.ugcpSITE_ID_CURRENT1.ColumnKey].Text; Thank you, Matt!
Chris
I'm sorry, but I previously replied and only included a couple screens shots without any meaningful reply. :(In my btnOk_Click method (code behind the OK button on the RowEditTemplate), I'm trying to retrieve the Value, but Intellisense does not provide that selection in the list. I included snapshots of the the properties associated with my UltraWinCombo and the ugcpsite_id_current field on the RowEditTemplate (that has the UltraWinCombo as its EditorControl). I'm trying to get the value from the ugcpsite_id_current field on the RowEditTemplate since that's the one the user is editing. Is that incorrect? Again, I have an UltraCombo as the EditorControl for the site column in my grid. Should I be using comboSiteLkup.value?
The UltraGridCellProxy simply hosts the underlying editor that is used in the cell of the currently edited row, so when the cell isn't in edit mode, as far as the proxy is aware, the Text is the value. If you need to get the true underlying value, you should get the value from the underlying cell. You can get this by accessing the Row from the RowEditTemplate and indexing into the Cells collection with the ColumnKey property on the proxy, i.e.:
object value = this.ultraGridRowEditTemplate1.Row.Cells[this.ugcpsite_id_current.ColumnKey].Value;
-Matt
WinCombo does have a Value property, and this is likely what you are looking for.
Depending on the method signature of your InsertBox() method, you may need to cast the combo's Value property to the appropriate class, since Value returns an object.