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
posted
I have a ultracombo 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, clinica FROM PACIENTES "
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

 

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 :

((System.Data.DataRowView)(ultraComboEditor1.SelectedItem.ListObject)).Row.ItemArray[2]

thanks
  • 469350
    Offline posted

    Hi,

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

    The easiest thing to do would be to simply use:

    Me.ClinicaCbx.SelectedRow.GetCellValue("Postal")

    alegar010 said:

    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 :

    ((System.Data.DataRowView)(ultraComboEditor1.SelectedItem.ListObject)).Row.ItemArray[2]

    I do not understand what you are asking here. The code you have here gets the underlying data object from the data source of the combo and returns it's value, but that's basically the same thing I did and my way is simpler, I think.