RSS

Monthly Archives: February 2013

set combo box datasourse in code in windows form application

//method to get datasource

public Dataset ViewDetails()

{      SqlConnection     cn =new SqlConnection(connstring);

SqlDataAdapter       adp =new SqlDataAdapter(“view”, cn);

adp.SelectCommand.CommandType =CommandType.StoredProcedure;

cn.Open();

Dataset   dt =new Dataset();

adp.Fill(dt);

cn.Close();

return dt;

}

//

//to load combo box with values

private void NewForm_Load(object sender, EventArgs e)

{

     DataSet ds = db.ViewDetails();

Combobox1.DataSource = ds;

Combobox1.DisplayMember =“Table.Id”;

Combobox1.ValueMember =“Table.Id”;

}

 
Leave a comment

Posted by on February 19, 2013 in c#.net

 

to get x y coordinates of an image in wp7

private void Image_Tapped_1(object sender, TappedRoutedEventArgs e)

{ txtName.Text = e.GetPosition((Image)sender).ToString(); }

 
Leave a comment

Posted by on February 17, 2013 in windows phone

 

to set image source of picturebox

using System.Drawing;

 

Image img=Image.FromFile(“D://picture path/pic.jpg”);

pictureBox1.Image = img;

 
Leave a comment

Posted by on February 17, 2013 in c#.net, wpf

 

encrypt passwords using Md5 encryption

using System.Text;
using System.Security.Cryptography;

static string getMd5Hash(string mdpassword)

{
MD5 md5Hasher = MD5.Create();
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(mdpassword));
StringBuilder sBuilder = new StringBuilder();

for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString(“x2”));

}
return sBuilder.ToString();
}

 
Leave a comment

Posted by on February 17, 2013 in asp.net, c#.net