How to write C# code on Windows Mobile

.NET programming topics
Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

How to write C# code on Windows Mobile

Post by Neo » Sun Feb 07, 2010 2:07 am

Here is an example C# code on Windows Mobile. Hope this will help you to give a start.

Code: Select all

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.Telephony;

namespace SmartDeviceProject1
{
    public partial class Form1 : Form
    {
        Random rnd = new Random(DateTime.Now.Millisecond);
        OutlookSession os = new OutlookSession();
        ContactCollection kontakte;

        public Form1()
        {
            InitializeComponent();
            kontakte = os.Contacts.Items;
            Contact meinKontakt = new Contact();
            meinKontakt.FirstName = "Harry";
            meinKontakt.LastName = "Potter";
            meinKontakt.MobileTelephoneNumber = "123456678";
            kontakte.Add(meinKontakt);
        }

      
        private void color_Click(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
        }

        private void menuExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnCall_Click(object sender, EventArgs e)
        {
            Phone meinHandy = new Phone();
            meinHandy.Talk("12312312");
        }

        private void btnSMS_Click(object sender, EventArgs e)
        {
            SmsMessage mySms = new SmsMessage();
            mySms.Body = "Call me after the meeting";
            mySms.To.Add(new Recipient("45645645"));
            mySms.Send();
            MessageBox.Show("Sent");
        }
    }
}
Post Reply

Return to “.NET Programming”