Solved

C#, PocketPC, step #2

Posted on 2003-11-03
4
274 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

11 Experts available now in Live!

Get 1:1 Help Now