How I can get the value of the column postal when I select a row?
Hello Alejandro,
Assuming that you are using UltraComboEditor and a DataTable as a DataSource you would be able to get the desired information using a code that is similar to the following one:
((System.Data.DataRowView)(ultraComboEditor1.SelectedItem.ListObject)).Row.ItemArray[2]
Where the "SelectedItem" is the current selected row in the UltraComboEditor, "ListObject" will return the object that is represented, and getting the ItemArray[2] will be the desired value that corresponds to the "Postal" value in the selected row, since it is the last column of your data source. ItemArray contains actually contains the columns in that case.
If you have any other questions please do not hesitate to ask me.
The environment of work is a visual basic 2010 and the control is Ultracombo , It is not a control ultracomboeditor It does not admit the property .SelectedItem.ListObject
I do not understand the instruction :
exemple
Dim ClinicasTb As DataTableDim bindingManager As BindingManagerBase
ClinicasTb = CargaClinicas()
Me.ClinicaCbx.DataSource = Me.ClinicasTb Me.ClinicaCbx.DataMember = "" Me.ClinicaCbx.ValueMember = "id" Me.ClinicaCbx.DisplayMember = "nombre" Me.ClinicaCbx.LimitToList = True Me.ClinicaCbx.MinDropDownItems = 5 Me.ClinicaCbx.MaxDropDownItems = 10
TABLE = CargaPacientes(Order, "") bindingManager = Me.BindingContext(TABLE)
Me.ClinicaCbx.DataBindings.Add("value", TABLE, "clinica")
Public Function CargaClinicas() As DataTable
Dim CLINICAS As New DataTable Dim MyConexion As OdbcConnection = New OdbcConnection(StrCon) Dim Sql As String
Sql = "Select id, nombre, postal FROM CLINICAS order by id "
Dim Adaptador As New OdbcDataAdapter(Sql, MyConexion)
Try MyConexion.Open() Adaptador.Fill(CLINICAS)
Catch ex As Exception MessageBox.Show("Error al cargar CLINICAS") Finally MyConexion.Close() End Try
Return CLINICAS
Public Function CargaPacientes() As DataTable
Dim PACIENTES As New DataTable Dim MyConexion As OdbcConnection = New OdbcConnection(StrCon) Dim Sql As String Sql = "Select id, nif, nombre, apellidos, apellidos + ', ' + nombre as MyNombre, via, direccion, Provincia, Localidad, " _ + " Postal, Telefono, Movil, Telefono2, Email, Nacimiento, Aseguradora, Antmedicos, Antdentales, Alergias, Relacion, " _ + " Dudoso, Clinica, Tarifa, Bonificacion, Old " _ + " FROM PACIENTES order by " + Order
Try MyConexion.Open() Adaptador.Fill(PACIENTES)
Catch ex As Exception MessageBox.Show("Error al cargar grid de pacientes") Finally MyConexion.Close() End Try
Return PACIENTES
End Function