Tuesday, May 27, 2014

Listview control in .net compact framework

Step 1: Drag a listview control on to the form.
Step 2 : Go to the code page and write the following where you need to write acc. to your conditions.
               listview1.view = view.detail; // indicating in which way you want to show the data in liastview
               listview1.dock = dockstyle.fill; //styling listview control to be filled acc. to form.
          
//  Adding columns to the listview
// listview1.column.add("column name",width of column,horizontalalignment.left);
   listview1.column.add("",80,horizontalalignment.left);
   listview1.column.add("Name",80,horizontalalignment.left);
   listview1.column.add("Age",50,horizontalalignment.left);

// Creating imagelist to store images which are to shown in listview.
     Int index = 0; // requires for indexing of the images in imagelist
    Imagelist imglst = new imagelist();
    Imagelist.Imagesize =   new Size(90,60);//Set imagesize of the image to be displayed in listview
    imglst.images.add(image address);
    index= index+1; // index to be incremented if you want to add  more images in your imagelist

// using imagelist witrh imagelist
listview1.smallimagelist = imglst; // assigning imagelist to listview
// ctreating listviewitem
 listviewitem itm = new listviewitem();
itm.imageindex = index;
itm.subitem.add("aman"); // this will add aman to the column1 which we declared above.
itm.subitem.add("24"); // this will add 24 to column2
// adding itm to listview
listview1.items.add(itm);

OUTPUT:

-->

Name
Age
Image



Aman



 24




 

Wednesday, February 10, 2010

Retrieve Contacts in .net compact framework developing window mobile Application

First Add two namespaces to the form

using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.Telephony;

Make objects of Contact Class

private OutlookSession _outlooksession;
private Contact _contactselected;

Madea method to populate contacts from device into your own application e.g. i take it in listbox

private void IntializeListBox()
{
this.listBox1.DataSource = null;
this.listBox1.DataSource = _outlooksession.Contacts.Items;
this.listBox1.DisplayMember = "FileAs";
this.listBox1.ValueMember = "ItemId";

}

Call this method in form constructor

public Second()
{
_outlooksession = new OutlookSession();
InitializeComponent();
this.IntializeListBox();
}

When you run the application listbox will show the contacts which are stored in device.

Tuesday, February 9, 2010

Fetch value from a particular cell of Datagrid in .net compcat farmework in developing Window Mobile Application

Step 1 : Made an object of datagridcell.
DataGridCell currentcell;
Step 2 : Take a string to store the data which is in the cell you want to select.
String currentcelldata;
Step 3 : Assign the data of datagrid current cel too the string.
currentcell = dataGrid1.CurrentCell; // Determing the currentcell of
datagid.
currentcelldata = (String)dataGrid1[currentcell.RowNumber, currentcell.ColumnNumber];
// Assigning data .Now the adat of currentcell is in currentcelldata.

Monday, February 1, 2010

Fetch Image from url in .net Compact Framework

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(getmdthumb.Url);
myRequest.Method = "GET";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
myResponse.Close();
picturebox1.image = bmp; // assigning image to picturebox

Saturday, January 30, 2010

play video from url

ProcessStartInfo mediastartinfo;
objprocess = new Process();
mediastartinfo = new ProcessStartInfo(@"windows\wmplayer.exe",url);
objprocess.StartInfo = mediastartinfo;
objprocess.Start();

Thursday, January 28, 2010

Use of splashform in Window Mobile Application

To add a splash screen form to your Application .follow the below code ---->>

-->> Take a new window form form2.cs
-->> Go to the code page of your Application First form
-->> Make an object Of the Splash form i.e form2.cs
private form2 frm2;
-->> Above Intializecomponent() method
-->> frm2 = new form2();
frm2.owner = this;// owner of form2 is current form
Application.doevents();
this.visible=false;
frm2.show();
-->> Below form1 load()
thread.sleep(5000); //Add namespace System.threading
this.visible= true;
this.enabled = true;
frm2.close();

Wednesday, January 27, 2010

Remove flickring of listview control in .net compact framework

to do this write only two lines
---->>>
----->>>
listview1.beginupdate();
write code of adding items to listview
listview1.endupdate();