Solved

C#, PocketPC, step #2

Posted on 2003-11-03
4
275 Views
Last Modified: 2010-04-16
I wrote these few C# lines in .NET Compact Framework:

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace SmartDeviceApplication
{
      public class Form1:Form
      {                        
            Button btnTest = new Button();
            Panel pnlTest;          
            public Form1()
            {
                  this.Text="Just4Fun";
                  // the panel...
                  pnlTest=new Panel();
                  pnlTest.Size=new Size(200,200);
                  // ...and BackColor works fine...
                  pnlTest.BackColor=Color.Yellow;
                  // the button...
                  btnTest=new Button();                  
                  btnTest.Size=new Size(150,100);
                  btnTest.Location=new Point(25,50);
                  // ...and the back color is always gray!
                  btnTest.BackColor=Color.Purple;
                  // papaya???
                  btnTest.ForeColor=Color.PapayaWhip;
                  btnTest.Text="PURPLE RAIN...\ntest";
                  // the event OnClick
                  //btnTest.Click+=new EventHandler(btn_clk);
                  pnlTest.Controls.Add(btnTest);
              this.Controls.Add(pnlTest);
            }                                           
 
            private static void Main()
            {
                  Application.Run(new Form1());
            }                      
 
      }
}

and the panel "BackColor" is working fine but the button "Back & ForeColor" are not working.
What I did wrong?

...maybe my .NET is a Balck&White version??? :-)

Thanks 4 your help...
0
Comment
Question by:ellerre
  • 3
4 Comments
 
LVL 6

Expert Comment

by:purpleblob
ID: 9672664
What version of Compact Framework are you using, I believe CF 1.0's Buttons did not actually implement the BackColor property whereas SP2 supposedly has addressed the lack of the BackColor implementation.
0
 
LVL 6

Expert Comment

by:purpleblob
ID: 9672747
Umm, interestingly I've looked into this a little further as I just realised I haven't got SP2 :-) and Compact Framework SP2 appears to have been recalled "because of some issues" whatever that means.
0
 

Author Comment

by:ellerre
ID: 9674184
I should have the last version of both .NET 2003 and Compact Framework.
I'm saying "should" because, if i try to update it, the answer is: "You have the last version... No upgrade avaiable" (bad translation from italian language, I know).

The best is that a lot of examples from Microsoft are not working because or a "method is not valid" or "this class do not accept only 2 parameters" and so on.

well...  another Plug and... Pray system?






0
 
LVL 6

Accepted Solution

by:
purpleblob earned 250 total points
ID: 9674403
Well, I've tried your example on my VS .NET 2003 and got the same problem you had, when I checked this out further I found this information saying that SP2 fixed this problem, but upon searching for the update found the links broken and then eventually found the comment that said the service pack had been recalled.

So basically, I'm afraid, it would look like you've a version which doesn't have SP2 on, in which case I'm afraid it would appear you cannot change the colour of the button.

However this said, you could ofcourse create your own button either as a UserControl or using something like a PictureBox to replace your Button objectand there you can obviously implement your own BackColor style capabilities.

Sorry I couldn't help further
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now