//Clear Old Node's
[HTML]treeView1.Nodes.Clear();
//Creat New Root Node
TreeNode tn = new TreeNode("new Node1");
//Creat Chid Node's
tn.Nodes.Add("Node1 Node1");
tn.Nodes.Add("Node1 Node2");
tn.Nodes.Add("Node1 Node3");
//Add Child Node's To TreeView
treeView1.Nodes.Add(tn);
//Creat New Root Node
TreeNode tn2 = new TreeNode("new Node2");
//Creat Chid Node's
tn2.Nodes.Add("Node2 Node1");
tn2.Nodes.Add("Node2 Node2");
//Creat New RootNode of Tn2
TreeNode tn3 = new TreeNode("Node2 Node3");
//Add Child's node to Node2 Node3
tn3.Nodes.Add("Node2 Node3 Node1");
tn3.Nodes.Add("Node2 Node3 Node2");
//Add New Root Node to Tn2
tn2.Nodes.Add(tn3);
//Add New Node To TreeView
treeView1.Nodes.Add(tn2);[/HTML
for (int i = 0; i < Controls.Count; i++)
**
Type tp = Controls[i].GetType();
if (tp.Name == "TextBox")
**
Controls[i].Text = "";
}
}
try
**
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
byte[] arrImage = ms.GetBuffer();
ms.Close();
SqlConnection con = new SqlConnection("server=(local);trusted_connection=y es;database=DbName;");
string strSQL = "INSERT INTO TabeName (filename,pic,id) VALUES ( @filename, @pic,@id)";
SqlCommand cmd = new SqlCommand(strSQL, con);
cmd.Parameters.Add(new SqlParameter("@filename", SqlDbType.Char, 50)).Value = textBox2.Text;//filename
cmd.Parameters.Add(new SqlParameter("@pic", SqlDbType.Binary)).Value = arrImage;//picture
cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Char, 50)).Value = textBox3.Text;//id
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Insert completed seccessfully.");;
}
catch (Exception ex)
**
MessageBox.Show(ex.Message);]
}
DataGridViewSelectedRowCollection q = dataGridView1.SelectedRows;
for (int i = 0; i < q.Count; i++)
**
dt.Rows.Remove(dt.Rows.Find(q[i].Cells[0].Value));
}
//SaveFileDialog saveFileDlg = New SaveFileDialog();
if (saveFileDlg.ShowDialog() == DialogResult.OK)
**
try
**
//Create Bitmap
Bitmap bimg = (Bitmap)this.pictureBox1.Image;
//Save Bitmap to file
bimg.Save(saveFileDlg.FileName,System.Drawing.Imag ing.ImageFormat.Jpeg);
}
catch (Exception ex)
**
MessageBox.Show(ex.Message, "MDI Sample", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void printToolStripButton_Click(object sender, EventArgs e)
**
try
**
op = new OpenFileDialog();
op.ShowDialog();
//MessageBox.Show(op.FileName);
filePath = op.FileName;
streamToPrint = new System.IO.StreamReader(filePath);
printFont = new System.Drawing.Font("Tahoma", 8);
System.Drawing.Printing.PrintDocument PD = new System.Drawing.Printing.PrintDocument();
PD.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PD_P rintPage);
PD.Print();
try
**
}
finally
**
streamToPrint.Close();
}
}
catch (System.Exception ex)
**
System.Windows.Forms.MessageBox.Show(ex.Message, "Error");
}
}
private void PD_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
**
float linesPerPage = 0;
float yPos = 0;
int count = 0;
using System.Runtime.InteropServices;
using System.Text;
...
public static void Main( )
**
int result = mciSendString
("set cdaudio door open", null, 0, IntPtr.Zero);
result =
mciSendString ("set cdaudio door closed",
null, 0, IntPtr.Zero);
**
[DllImport("winmm.dll", EntryPoint="mciSendStringA", CharSet=CharSet.Ansi)]
protected static extern int mciSendString
(string mciCommand,
StringBuilder returnValue,
int returnLength, IntPtr callback);
public Image Resize(Image img, int percentage)
**
//get the height and width of the image
int originalW = img.Width;
int originalH = img.Height;
//get the new size based on the percentage change
int resizedW = (int)(originalW * percentage);
int resizedH = (int)(originalH * percentage);
//create a new Bitmap the size of the new image
Bitmap bmp = new Bitmap(resizedW, resizedH);
//create a new graphic from the Bitmap
Graphics graphic = Graphics.FromImage((Image)bmp);
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
//draw the newly resized image
graphic.DrawImage(img, 0, 0, resizedW, resizedH);
//dispose and free up the resources
graphic.Dispose();
//return the image
return (Image)bmp;
**
try
**
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
byte[] arrImage = ms.GetBuffer();
ms.Close();
SqlConnection con = new SqlConnection("server=(local);trusted_connection=y es;database=DbName;");
string strSQL = "INSERT INTO TabeName (filename,pic,id) VALUES ( @filename, @pic,@id)";
SqlCommand cmd = new SqlCommand(strSQL, con);
cmd.Parameters.Add(new SqlParameter("@filename", SqlDbType.Char, 50)).Value = textBox2.Text;//filename
cmd.Parameters.Add(new SqlParameter("@pic", SqlDbType.Binary)).Value = arrImage;//picture
cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Char, 50)).Value = textBox3.Text;//id
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Insert completed seccessfully.");;
**
catch (Exception ex)
**
MessageBox.Show(ex.Message);
**
private void EmptyCacheFolder(DirectoryInfo folder)
**
//loop through all the files in the folder provided
foreach (FileInfo file in folder.GetFiles())
**
file.Delete();
}
foreach (DirectoryInfo subfolder in folder.GetDirectories())
**
//recursively delete all files and folders in each sub directory
EmptyCacheFolder(subfolder);
}
}
public bool ClearCache()
**
//variable to hold our status
bool isEmpty;
try
**
//call EmptyCacheFolder passing the default internet cache
//folder
EmptyCacheFolder(new DirectoryInfo(Environment.GetFolderPath(Environmen t.SpecialFolder.InternetCache)));
isEmpty = true;
}
catch
**
isEmpty = false;
}
return isEmpty;
}
// array of integers to hold values
private int[] a = new int[100];
private int[] b = new int[100];
// number of elements in array
private int x;
// Merge Sort Algorithm
public void sortArray()
**
m_sort( 0, x-1 );
}
public void m_sort( int left, int right )
**
int mid;
if( right > left )
**
mid = ( right + left ) / 2;
m_sort( left, mid );
m_sort( mid+1, right );
merge( left, mid+1, right );
}
}
public void merge( int left, int mid, int right )
**
int i, left_end, num_elements, tmp_pos;
left_end = mid - 1;
tmp_pos = left;
num_elements = right - left + 1;
while( (left <= left_end) && (mid <= right) )
**
if( a[left] <= a[mid] )
**
b[tmp_pos] = a[left];
tmp_pos = tmp_pos + 1;
left = left +1;
}
else
**
b[tmp_pos] = a[mid];
tmp_pos = tmp_pos + 1;
mid = mid + 1;
}
}
while( left <= left_end )
**
b[tmp_pos] = a[left];
left = left + 1;
tmp_pos = tmp_pos + 1;
}
while( mid <= right )
**
b[tmp_pos] = a[mid];
mid = mid + 1;
tmp_pos = tmp_pos + 1;
}
for( i = 0; i < num_elements; i++ )
**
a[right] = b[right];
right = right - 1;
}
}
for (int i = 0; i < strContain.Length; i++)
{
listBox1.Items.Add(strContain[i]);
Thread.Sleep(100);
}
سلام لطفا کد مربوطه به text boxرو بذارید که وقتی رمز عبور وارد میکنیم،بجای پسورد علامت * رو نشون بده.ممنون