Solved

C#, PocketPC, step #2

Posted on 2003-11-03
4
277 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 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