Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
ALEJANDRO GARCIA
posted

 

I have a ultracombot control with 3 columns (Id, Nombre, Postal)
Dim ClinicasTb As DataTable
Dim 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
       
        Dim Adaptador As New OdbcDataAdapter(Sql, MyConexion)
        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



How I can get the value of the column postal when I select a row?

 thanks
Parents
  • 20872
    Offline posted

    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.

     

Reply Children