CF 2 + Variable with Button function

  • Thread starter Thread starter Mario.Lung
  • Start date Start date
M

Mario.Lung

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
 
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
 
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
 
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
 
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
 
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
 
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 MVPwww.peterfoot.net|www.inthehand.com














- Zitierten Text anzeigen -

thx works now
 
Back
Top