I want to "fill" an ultracombo so a grid can be populated based on the ValueMember that is choosen from. Here's the following code.
public void FillCombo(){ conn = new SqlConnection(MSSQL); cmd = new SqlCommand(); cmd.Connection = conn; conn.Open(); cmd.CommandType = CommandType.Text; cmd.CommandText = @"SELECT RTRIM(NOMBRE_ESQUEMA) as NOMBRE_ESQUEMA, ESQUEMA FROM dbo.COMISIONES_ESQUEMAS;"; MyReader = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(MyReader);
if (dt.Rows.Count > 0){ this.eucEsquema.DataSource = dt; this.eucEsquema.DisplayMember = "NOMBRE_ESQUEMA"; this.eucEsquema.ValueMember = "ESQUEMA"; } conn.Close(); cmd.Dispose();
}
The problem here is that whenever I click the ultracombo box, both DisplayMember and ValueMember appears and I only want the user to see the DisplayMember. I don't want them to actually see the ValueMember cause if they do, maybe they'll get confused.
NOTE: I want the ValueMember to be available, but not displayed on the ultracombo box
Is there a way to achieve this?
Thanks
Hi William,
Yes, this is very easy to do. Just hide the column.
private void ultraCombo1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { var layout = e.Layout; var band = e.Layout.Bands[0]; band.Columns["ESQUEMA"].Hidden = true; }
private void ultraCombo1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { var layout = e.Layout; var band = e.Layout.Bands[0];
band.Columns["ESQUEMA"].Hidden = true; }
Thanks Mike, that worked.
Following up on the question, what If i have a composite key on my database? Is it possible to assign "ValueMember" two times?
Let's say that my composite key consists of an Invoice Number field and an Invoice Line field, how can I access both values?