Problem With listbox

jothis

Active Member
Licensed User
Here Whe I Clicked On the Edit Button

Iwant To change The Selected Index To The Result Of Selected Item Of Te Table I used Something Like This

For i=0 To ListBox3.Count-1
If GETSUBJ=ListBox3.Item(i) Then
ListBox3.SelectedIndex=i
Exit
End If

But It Is Not Working
Any One Can Help Me?
jothis
:sign0085:
 

Attachments

  • 1.zip
    2.6 KB · Views: 215

sitajony

Active Member
Licensed User
Hi, So the index is not selected? Are you sure that GETSUBJ is = to one of listbox items? Maybe there're an error on UpperCase, Space etc...

Try this:

B4X:
For i=0 To ListBox3.Count-1
If StrToLower(GETSUBJ)=StrToLower(ListBox3.Item(i)) Then
ListBox3.SelectedIndex=i
Exit
End If
 

jothis

Active Member
Licensed User
But The Problem Is Still Exist

Thanks For Your Help But The Problem Is Still Exist
 

sitajony

Active Member
Licensed User
His problem is when he click on "Edit", The Option is selected but apparently it doesn't... I'm checking where is the problem exactly...

Edit:
Problem found:
Your ListBoxs doesn't correspond to your Field... I think that your Course and Subject ListBox are inverted... So it's normal if your code doesn't find...

Here is the problem resolved:
B4X:
      For i=0 To ListBox3.Count-1
      If GETCOURES=ListBox3.Item(i) Then
         ListBox3.SelectedIndex=i
         Exit
      End If
      Next
      
      For i=0 To ListBox2.Count-1
      If GETSUBJ=ListBox2.Item(i) Then
         ListBox2.SelectedIndex=i
         Exit
      End If
      Next

I think that there's a problem when your read your database...
Good Luck
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…