Forcing an Item_Click event

Galbas

Member
Licensed User
Longtime User
Hi people!
I have got an index in my table and I am trying to force the item_click event. The name in spinner shows me perfectly but it doesn't run the item_click event. How can I do this task?
Thanks,
Galbas
 

joseluis

Active Member
Licensed User
Longtime User
You can always call the sub directly (e.g. item_Click) when you want.

If that doesn't solve it, then you'll have to explain a little bit more your case and/or share some source code because it's not clear for me what you want to do.
 
Upvote 0

Galbas

Member
Licensed User
Longtime User
Hi Joseluis!

The line below shows me the correct name in spinner but I am sure that
event Item_Click is not called. Any idea?

cboUnidNorEns.SelectedIndex = Cursor1.GetString("Unid")

Thanks,
Galbas
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
I still don't see anything.

The Click event is handled automatically when you click on the view that you had previously initialized with an EventName which must have the same name as the base name of the sub.

Without the relevant source code I can't see what's wrong, I'm sorry.
 
Upvote 0

Galbas

Member
Licensed User
Longtime User
I will try to explain a little more. The program reads a table (alone) and shows me the value in the spinner but the event click doesn't run.
Note: All happens without user interaction.
Thanks,
Galbas
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
Can't you share a minimal example? If not I'm gonna have to pass on this because I really don't understand what you want to do, I'm sorry.
 
Upvote 0

Galbas

Member
Licensed User
Longtime User
Follows a part of my code.
The red line doesn't invoke cboUnidNorEns_ItemClick
Thanks,
Galbas

Sub cboUnidNorEns_ItemClick (Position As Int, Value As Object)
Select Case Position
Case 0'kgf.mm
UnidCargaEns = "kgf"
UnidDeslEns = "mm"
Case 1'kgf.cm
UnidCargaEns = "kgf"
UnidDeslEns = "cm"
Case 2'kgf.in
UnidCargaEns = "kgf"
UnidDeslEns = "in"
Case 3'N.mm
UnidCargaEns = "N"
UnidDeslEns = "mm"
Case 4'N.cm
UnidCargaEns = "N"
UnidDeslEns = "cm"
Case 5'N.m
UnidCargaEns = "N"
UnidDeslEns = "m"
Case 6'daN.mm
UnidCargaEns = "daN"
UnidDeslEns = "mm"
Case 7'kN.mm
UnidCargaEns = "kN"
UnidDeslEns = "mm"
Case 8'kN.m
UnidCargaEns = "kN"
UnidDeslEns = "m"
Case 9'gfmm
UnidCargaEns = "gf"
UnidDeslEns = "mm"
Case 10'gf.in
UnidCargaEns = "gf"
UnidDeslEns = "in"
Case 11'lb.in
UnidCargaEns = "lb"
UnidDeslEns = "in"
End Select
lblUnidCMP.Text = UnidCargaEns
lblUnidDMP.Text = UnidDeslEns
lblUnidL0.Text = UnidDeslEns
lblUnidLarg.Text = UnidDeslEns
lblUnidEsp.Text = UnidDeslEns
lblUnidDExt.Text = UnidDeslEns
lblUnidDInt.Text = UnidDeslEns
lblUnidCTot.Text = UnidDeslEns
lblUnidArea.Text = UnidDeslEns & "²"
End Sub

Sub LeNormaEns(Posicao As Int)
Dim Cursor1 As Cursor
Cursor1 = SQL1.ExecQuery("SELECT * FROM " & tableNorEns)
Cursor1.Position = Posicao
Try
cboUnidNorEns.SelectedIndex = Cursor1.GetString("Unid") :NE.Unid= cboUnidNorEns.SelectedIndex
txtCMP.Text = Cursor1.GetString("CMP") :NE.CMP = txtCMP.text
txtDMP.Text = Cursor1.GetString("DMP") :NE.DMP = txtDMP.text
txtPCarga.Text = Cursor1.GetString("PCarga") :NE.DMP = txtPCarga.text
txtRupt.Text = Cursor1.GetString("Rupt") :NE.DMP = txtRupt.text
txtColapso.Text = Cursor1.GetString("Colapso") :NE.DMP = txtColapso.text
txtTA.Text = Cursor1.GetString("TA") :NE.DMP = txtTA.text
txtUR.Text = Cursor1.GetString("UR") :NE.DMP = txtUR.text
txtVeloc.Text = Cursor1.GetString("Veloc") :NE.DMP = txtVeloc.text
cboFiltro.SelectedIndex = Cursor1.GetString("Filtro") :NE.DMP = cboFiltro.SelectedIndex
txtL0.Text = Cursor1.GetString("L0") :NE.DMP = txtL0.text
cboArea.SelectedIndex = Cursor1.GetString("TipoArea") :NE.DMP = cboArea.SelectedIndex
txtLargura.Text = Cursor1.GetString("Larg") :NE.DMP = txtLargura.text
txtEspessura.Text = Cursor1.GetString("Esp") :NE.DMP = txtEspessura.text
txtDiamExt.Text = Cursor1.GetString("DExt") :NE.DMP = txtDiamExt.text
txtDiamInt.Text = Cursor1.GetString("DInt") :NE.DMP = txtDiamInt.text
txtArea.Text = Cursor1.GetString("Area") :NE.DMP = txtArea.text
txtComprimento.Text = Cursor1.GetString("Comp") :NE.DMP = txtComprimento.text
txtPeso.Text = Cursor1.GetString("Peso") :NE.DMP = txtPeso.text
txtPesoEsp.Text = Cursor1.GetString("PesoEsp") :NE.DMP = txtPesoEsp.text
chkRetFCurso.Checked = (Cursor1.GetString("FCurso") = True) :NE.DMP = chkRetFCurso.Checked
chkRetornoAuto.Checked = (Cursor1.GetString("RetAuto") = True) :NE.DMP = chkRetornoAuto.Checked
'Change_Unidade_Ens(NE.Unid)
Catch
Msgbox ("Norma de ensaio corrompida!","Normas de Ensaios")
End Try
Cursor1.Close

End Sub
 
Upvote 0

Galbas

Member
Licensed User
Longtime User
No, imagine that you made a small program with a called in Activity_Create
sub Activity_Create
cboUnidNorEns.Clear
cboUnidNorEns.AddAll(Array As String("kgf.mm","kgf.cm","kgf.in","N.mm","N.cm","N.m","daN.mm","kN.mm","kN.m","gf.mm","gf.in","lb.in"))
cboUnidNorEns.SelectIndex = 1
end sub

This shows me kgf.cm in cboUnidNorEns(Spinner) but doesn't active the cboUnidNorEns_ItemClick

I hope you understand now.
It seems easy but is so hard to explain
Thanks,
Galbas
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
Since I've not used databases with b4a yet, and your problem seems very tied to the usage of databases, plus without a full code example to compile and debug I don't fill confident to point you in the right direction. So I'm gonna step out and let another one to help you. I'm sorry and good luck.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
From what I know, when you set the SelectedItem property of a Spinner it doesn't raise the ItemClick event.
If you need it you must call after the SelectedItem line
B4X:
cboUnidNorEns_ItemClick(SelectedItem, cboUnidNorEns.GetItem(SelectedItem))

Best regards.

 
Upvote 0
Top