Groups | Blog | Home
all groups > dotnet compact framework > may 2007 >

dotnet compact framework : CF 2 + Variable with Button function


Mario.Lung NO[at]SPAM gmail.com
5/14/2007 2:48:44 AM
Hi there

how i can made this

me.variable.backcolor = DrawingSystems.Red
me(variable).backcolor = DrawingSystems.Red

this dosent work pleas help me

thx

Mario
Mario.Lung NO[at]SPAM gmail.com
5/14/2007 5:03:42 AM
Hi,

I have 32 Bottons on a Form
and via sql i make a call to a tabel
in the table there is the button name and the color saved

so i made a sql statement
there call all buttons there are red

then write the name in a variable

ok now beginn my problem

i have the variable with the name of the button

in this button must be set the backcolor to red

sry for my english my fav language is german

thx

Mario

work with VS2005 Professional - Compact Framework 2 / Mobile SQL
Server 2005





On 14 Mai, 12:47, "Peter Foot [MVP]" <feedb...@nospam-inthehand.com>
[quoted text, click to view]

ctacke/
5/14/2007 8:01:15 AM
As Peter points out, it's not at all clear what you're doing. If
you'resaying you're setting the backcolor of a control and it's not doing
anything (but it is not throwing an exception) and if you're running CF 1.0,
make sure it's SP3, as the RTM and maybe SP1 didn't work for these. If this
isn't the case, you need to tell us more.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


[quoted text, click to view]

ctacke/
5/14/2007 8:23:47 AM
You need to use reflection to get the instance of the control with the name,
get the backcolor property setter and then you can use that to set the
color.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


[quoted text, click to view]

Peter Foot [MVP]
5/14/2007 11:47:39 AM
First things first - what are you trying to achieve? Secondly, what errors
are you getting with this approach (there is no such class as DrawingSystems
for a start...

Assuming you have a button on your form called myButton, you would set it's
back color like this:-
Me.myButton.BackColor = System.Drawing.Color.Red

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

[quoted text, click to view]
Peter Foot [MVP]
5/14/2007 1:25:57 PM
The ControlCollection class which has the collection of controls for a form
or container, doesn't support accessing controls by name in the Compact
Framework. You could loop through the collection until you find the required
control, or you could use reflection to get hold of a specific control.

For Each c As Control in Me.Controls

If c.Name == nameFromDatabase Then
c.BackColor = Color.FromArgb(colorValueFromDatabase)
End If
Next

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

[quoted text, click to view]
Mario.Lung NO[at]SPAM gmail.com
5/15/2007 1:49:50 AM
On 14 Mai, 14:25, "Peter Foot [MVP]" <feedb...@nospam-inthehand.com>
[quoted text, click to view]

thx works now

AddThis Social Bookmark Button