Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Enhanced ComboBox / Listbox

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2009, 01:38 AM
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default Enhanced ComboBox / Listbox

What can someone use for a Combobox on the device to accept input too?
A library of somekind?
Reply With Quote
  #2 (permalink)  
Old 02-06-2009, 05:39 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Dragonspank,
This was my old trick, I use textbox infont of the combobox...
see sample attached...
Attached Files
File Type: sbp Cbi1.sbp (960 Bytes, 121 views)
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB
Reply With Quote
  #3 (permalink)  
Old 02-06-2009, 07:25 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Rioven,

I had a look at your trick, and have two comments.

- In my programs I use too a separate TextBox, but not overlapping the ComboBox, and two buttons, one to add the TextBox.Text at the end of the list and the second one to modify the selected item. I miss the last function in your trick.

- Your code:
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Sub </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">Combobox1_SelectionChanged(Index,Value)</font></font>
<font size=
"2"><font face="Courier New">textbox1.Text=Combobox1.Item(Combobox1.SelectedIndex)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
can be simplified by this one:
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Sub </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">Combobox1_SelectionChanged(Index,Value)</font></font>
<font size=
"2"><font face="Courier New">textbox1.Text=Value</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #4 (permalink)  
Old 02-06-2009, 08:35 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks Klaus! I've missed that code!
Sure, we could do many tricks/features on textbox and combobox combination on what you want to achieve. My sample is just adding items but cannot edit. You may post yours.

Regards,
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB
Reply With Quote
  #5 (permalink)  
Old 02-07-2009, 12:07 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Rioven,

Here is an example how I use ComboBoxes and or ListBoxes in some of my programs.
I added also a ListBox, the princilpe is exactly the same as for the ComboBox but it shows better what happens.

You can:
- move items up and down
- insert an item on the selected position
- add an item at the end
- delete an item

Best regards.

EDIT: Removed the code, a new one is in post #7
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 02-08-2009 at 05:25 PM.
Reply With Quote
  #6 (permalink)  
Old 02-08-2009, 05:00 PM
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default

Nice! Thanks Rioven! Managed an implementation into my application.

Klaus, your code looks sweet, but I get an error in line 14 with the index value of 5 being not valid. So what is amiss with your ComboBoxTest?

Thanks again for the great help!
Reply With Quote
  #7 (permalink)  
Old 02-08-2009, 05:23 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Here is the correct code.

I added the listbox later on and didn't test every thing again.

Sorry for that and best regards.

EDIT: Removed code, new code in post #11
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 02-10-2009 at 07:35 AM.
Reply With Quote
  #8 (permalink)  
Old 02-08-2009, 06:03 PM
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default

Excellent!!!!
In my humble newbie opinion:
I think this should make it to a Sticky somewhere on this forum!

Thank you all for this fantastic support!!
Reply With Quote
  #9 (permalink)  
Old 02-09-2009, 06:19 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Edit: Moved thread to Code samples and changed thread's name.
Reply With Quote
  #10 (permalink)  
Old 02-10-2009, 03:41 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
Here is the correct code.

I added the listbox later on and didn't test every thing again.

Sorry for that and best regards.
Hello Klaus,
I've tested your code...pretty NICE!
When you make the listbox empty and press the delete or insert button it triggers error.

I have just added the conditions something like this, then it works...or you can have better solutions.

Code:
Sub btnDelete_Click
    <b>
If cbxTest.Count>0 Then</b>
        cbxTest.RemoveAt(SelI)
        lbxTest.RemoveAt(SelI)
        
If SelI>cbxTest.Count-1 Then
            SelI=SelI-
1
        
End If
        cbxTest.SelectedIndex=SelI
        lbxTest.SelectedIndex=SelI
    <b>
End If    </b>
End Sub

Sub btnInsert_Click
    <b>
If cbxTest.Count>0 Then</b>
        cbxTest.Insert(SelI,txtTest.Text)
        lbxTest.Insert(SelI,txtTest.Text)
        cbxTest.SelectedIndex=SelI
        lbxTest.SelectedIndex=SelI
    <b>
End If    </b>
End Sub
Regards,
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enhanced form controls digitaldon37 Questions (Windows Mobile) 1 11-21-2008 07:17 AM
Listbox and enter key tsteward Questions (Windows Mobile) 2 10-14-2008 06:30 AM
How to fix ListBox Items? Stellaferox Questions (Windows Mobile) 12 02-22-2008 09:50 AM
Listbox difficulties. dan kabestan Questions (Windows Mobile) 2 12-15-2007 06:24 PM
listbox = arraylist ? sloopa Questions (Windows Mobile) 1 05-07-2007 12:38 PM


All times are GMT. The time now is 10:25 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0