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

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

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Setting color of controls on runtime

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-07-2008, 06:13 AM
RGS RGS is offline
Junior Member
 
Join Date: Aug 2008
Posts: 10
Default Setting color of controls on runtime

This fragement of code:

Controls() = GetControls("frmMain")
For i = 0 To ArrayLen(Controls())-1
If ControlType(Controls(i)) = "Label" Then
Control(Controls(i)).Color = cWhite
End If
Next

does not seem to work in my application. During execution the error "If ControlType(Controls(i)) = "Label" Then Error Description: Object reference not set to an instance of an object" is raised.

Types of controls on my form: TabControl, Labels, TextBox, Images and Listbox

Am I overlooking something? Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 09-07-2008, 07:46 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Italy
Posts: 599
Awards Showcase
Beta Tester 
Total Awards: 1
Default

This works (it is just like your code - the only difference is that I declared the array in the Global-part).

rgds,
moster67


Code:
Sub Globals
    
'Declare the global variables here.
    Dim controls(0)
End Sub

Sub App_Start
    
'frmMain.Show
    Controls() = GetControls("frmMain")
For i = 0 To ArrayLen(Controls())-1
If ControlType(Controls(i)) = "Label" Then
Control(Controls(i)).Color = cWHite
End If
Next

frmMain.Show
End Sub
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 08:04 AM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

The problem is the TabControl!
If I only used controls added by the designer, everything works fine (thats what moster67 surely did).
But the ControlType statement doesn't work for the TabControl. I'll get an "Unable to evaluate expression." in the debug mode.

I can't explain this behaviour because I'm not so familiar with the .Net and basic4ppc basics. Anyone?

specci48
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 12:43 PM
RGS RGS is offline
Junior Member
 
Join Date: Aug 2008
Posts: 10
Default

Ah, that's it. That only leaves setting the color manually for each component. Thanks.
Reply With Quote
  #5 (permalink)  
Old 09-08-2008, 11:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

This issue will be further checked.
In the meantime you can use:
Code:
Controls() = GetControls("form1")
For i = 0 To ArrayLen(Controls())-1
If <b>controls(i) <> ""</b> AND ControlType(Controls(i)) = "Label" Then
Control(Controls(i)).Color = cWhite
End If
Next
Reply With Quote
  #6 (permalink)  
Old 09-08-2008, 05:31 PM
RGS RGS is offline
Junior Member
 
Join Date: Aug 2008
Posts: 10
Default

Thanks Erel for your kind help (and great product BTW!!!)
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
Setting a font style to strikeout Ricky D Questions (Windows Mobile) 3 11-05-2008 07:59 PM
Setting #Region Form the IDE menu Cableguy Basic4ppc Wishlist 5 09-27-2008 10:18 PM
Removing controls in runtime Stanl3yCZ Questions (Windows Mobile) 1 02-18-2008 02:51 PM
Setting Control names as arrays. burd27 Questions (Windows Mobile) 6 01-29-2008 10:38 AM
Runtime controls manipulation Erel Tutorials 0 09-26-2007 01:18 PM


All times are GMT. The time now is 02:15 AM.


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