Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Changing tab order of controls while running


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2008, 11:00 AM
Knows the basics
 
Join Date: Aug 2007
Posts: 53
Default Changing tab order of controls while running

I know how to change the tab order of controls in the designer (send to back), but I have an application with some runtime generated controls.

Interestingly, the tab order is just the reverse of the generation order, which is slightly annoying (it would mean to use a For/Next Loop with STEP - 1 to get it all in the right order ;-)

Therefore it would be very nice to be able to manipulate the tab order differently. Is this possible?
Reply With Quote
  #2 (permalink)  
Old 01-11-2008, 01:13 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

You can use the lostfocus event to make the next control gain focus in the order you want...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 01-11-2008, 03:13 PM
Knows the basics
 
Join Date: Aug 2007
Posts: 53
Default Nice idea ...

... although a little bit like shooting yourself in the foot
Reply With Quote
  #4 (permalink)  
Old 01-11-2008, 06:15 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I don't really understand you'r comment...
You say it's a nice idea, but a bit like shooting yourself in the foot, why? it gets the job done...
Another way is to edit the spb file and invert the order of the control-creators code...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #5 (permalink)  
Old 01-11-2008, 11:17 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

I'm having the same issue - a program which creates a great many controls dynamically, which really screws up the tab order. In my case, I always want the tab order to be the same, so I could potentially use Cableguy's idea of using the lostFocus event.

Woinowski, it sounds as though you want to be able to manipulate the tab order any way you want. I haven't tried this one yet (probably will this weekend), but it might work...

Put an ArrayList on your form. Every time you create a control dynamically, put the name of the control into the list. When you're finished creating controls, run through all of the items in the array list and do something like:

Code:
sub form1_SetTabOrder
   For i = 0 to ArrayList1.Count - 1
      Control( ArrayList1.Item(i) ).BringToFront
   Next
end sub
You could alter the tab order by removing items from and inserting items into the array list; just be sure to call the subroutine again when you're done changing the contents of the list.

Like I say, I haven't tried this one yet.

Gary
Reply With Quote
  #6 (permalink)  
Old 01-14-2008, 09:16 AM
Knows the basics
 
Join Date: Aug 2007
Posts: 53
Default Why I think these solutions are strange

Simple: Setting Focus according to tab order is something that can be handled perfectly well by the Framework (CF) or the Operating System (Windows [Mobile]).

Also, it should be done this way.

Faking (overriding) a tab order by catching events is something only real programmers do. Have a look at this http://www.pbm.com/~lindahl/real.programmers.html

Probably you understand why I think this is shooting yourself into the foot. Hopefully, you haven't been offended by my answer.

PS: Feels also a little bit like back in the good old VIC 20 times.
Reply With Quote
  #7 (permalink)  
Old 01-14-2008, 09:57 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by Woinowski View Post
http://www.pbm.com/~lindahl/real.programmers.html

PS: Feels also a little bit like back in the good old VIC 20 times.
Thanks for the link, I remember when that was published though I haven't seen it for years, nor the story of Mel. I have saved them to show and explain the to a younger generation! As you and I, apparently being of a certain age, know there is MORE than an element of truth in those tales of the early days.

PS: TRS80-Model 1's set me off. - My brother was into Commodore Pets. Those machines set off the Motorola approach vs the Intel approach schism that persists in some form to this very day.
Reply With Quote
  #8 (permalink)  
Old 01-18-2008, 05:28 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default A problem with my approach...

I finally got around to trying the solution I suggested (placing the names of the controls in an arrayList, running through the list, and using .bringToFront to set the tab order).

The form this is called from contains a control called 'arrayFormMedsTabOrder'.

Here's the relevant code:

Code:
sub formMeds_Show

   ...

		arrayFormMedsTabOrder.Add( "formMedsHeader" )
		arrayFormMedsTabOrder.Add( "labelMedsNDC" )
		arrayFormMedsTabOrder.Add( "textMedsNDCLabeler" )
		arrayFormMedsTabOrder.Add( "labelMedsNDCSep" )
		arrayFormMedsTabOrder.Add( "textMedsNDCProduct" )
		arrayFormMedsTabOrder.Add( "labelMedsProduct" )
		arrayFormMedsTabOrder.Add( "textMedsProduct" )
		arrayFormMedsTabOrder.Add( "btnMedsSearch" )
		arrayFormMedsTabOrder.Add( "labelMedsGeneric" )
		arrayFormMedsTabOrder.Add( "textMedsGeneric" )
		arrayFormMedsTabOrder.Add( "btnMedsClear" )
		arrayFormMedsTabOrder.Add( "labelMedsDose" )
		arrayFormMedsTabOrder.Add( "textMedsDose" )
		arrayFormMedsTabOrder.Add( "labelMedsRoute" )
		arrayFormMedsTabOrder.Add( "comboMedsRoute" )
		arrayFormMedsTabOrder.Add( "labelMedsFrequency" )
		arrayFormMedsTabOrder.Add( "textMedsFrequency" )
		arrayFormMedsTabOrder.Add( "labelMedsDiagnosis" )
		arrayFormMedsTabOrder.Add( "textMedsDiagnosis" )
		arrayFormMedsTabOrder.Add( "btnMedsDXSearch" )
		arrayFormMedsTabOrder.Add( "btnMedsPrev" )
		arrayFormMedsTabOrder.Add( "btnMedsNext" )
		arrayFormMedsTabOrder.Add( "btnMedsMenu" )

		setFormTabOrder( "formMeds" )

   ...

end sub
and...

Code:
Sub setFormTabOrder( pArray )

	ctl = "array" & pArray & "TabOrder"
	
	For x = 0 To Control( ctl, ArrayList ).Count - 1
		Control( Control( ctl, ArrayList ).Item( x ) ).BringToFront
	Next

End Sub
The code produces no errors, but does not produce the desired tab order. In one place, it jumps halfway through the list; in another, it tabs backwards (relative to what I expect). It works properly on about the last half of the list.

Anyone have any ideas?



Gary

(I finally have a free weekend, so I'll have to spend some of it dusting off my TRS-80, Atari 2600, or maybe the Exidy Sorcerer... )

Last edited by willisgt : 01-18-2008 at 05:31 PM.
Reply With Quote
  #9 (permalink)  
Old 01-18-2008, 06:06 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Anyone have any ideas?
Not really - I am sure that the array list will be in the correct order. I would try excluding from the list the form and labels as they cannot gain the focus so are not really in the tab order - see if that makes a difference.
Reply With Quote
  #10 (permalink)  
Old 01-18-2008, 09:23 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

I removed all the labels from the list. Changing the code to:

Code:
		arrayFormMedsTabOrder.Add( "textMedsNDCLabeler" )
		arrayFormMedsTabOrder.Add( "textMedsNDCProduct" )
		arrayFormMedsTabOrder.Add( "textMedsProduct" )
		arrayFormMedsTabOrder.Add( "btnMedsSearch" )
		arrayFormMedsTabOrder.Add( "textMedsGeneric" )
		arrayFormMedsTabOrder.Add( "btnMedsClear" )
		arrayFormMedsTabOrder.Add( "textMedsDose" )
		arrayFormMedsTabOrder.Add( "comboMedsRoute" )
		arrayFormMedsTabOrder.Add( "textMedsFrequency" )
		arrayFormMedsTabOrder.Add( "textMedsDiagnosis" )
		arrayFormMedsTabOrder.Add( "textMedsDiagnosisDesc" )
		arrayFormMedsTabOrder.Add( "btnMedsDXSearch" )
		arrayFormMedsTabOrder.Add( "btnMedsPrev" )
		arrayFormMedsTabOrder.Add( "btnMedsNext" )
		arrayFormMedsTabOrder.Add( "btnMedsMenu" )
did not change the tab order.

The behavior is the same whether I'm just running the code (F5), or a compiled executable.

I've got to be missing something really simple here...

Gary
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the parent of a panel Ricky D Questions & Help Needed 1 10-05-2008 12:03 PM
Changing ROW color in Table? tcgoh Questions & Help Needed 0 04-07-2008 04:25 PM
'Tab' order of controls corwinckler Questions & Help Needed 1 12-18-2007 05:52 AM
Changing the size of a form magi6162 Questions & Help Needed 1 10-24-2007 08:38 AM
Tab Order for Controls BPak Questions & Help Needed 2 05-06-2007 06:58 AM


All times are GMT. The time now is 04:56 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0