كار با كنترل treeview در این مثال طریقه استفاده از کنترل TreeView به طور کاملا ساده و روان شرح داده شده است . برای استفاده های عملی تر باید این فرایند در حلقه های تودرتو و بر حسب نیاز پیاده سازی شود. نکته : این روش فقط در C# ( سی شارپ ) کاربرد دارد و برای استفاده در Asp.net باید تغییرات کوچکی را اعمال کنید. كد: //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[/LEFT] [/FONT][/COLOR][/COLOR] [COLOR=#000000][COLOR=#777777][FONT=tahoma] [COLOR=#666666] <blockquote class="postcontent restore " style="margin: 0px; padding: 0px; word-wrap: break-word;">[B]دسترسی به آرایه کنترل های موجود در فرم[/B] در این مثال با استفاده از آرایه کنترلهای موجود در فرم ، متن موجود در تکست باکس های موجود بر روی صفحه را تنظیم می نماییم. این روش در مواردی کاربرد دارد که TextBox های موجود در فرم زیاد باشد كد: [LEFT] [HTML]for (int i = 0; i < Controls.Count; i++) ** Type tp = Controls[i].GetType(); if (tp.Name == "TextBox") ** Controls[i].Text = ""; } } </blockquote> <blockquote class="signature restore" style="margin: 1em 0px 0px; padding: 1em 10px 0px; border-top: 1px solid rgb(233, 233, 233);"> <br class="Apple-interchange-newline"> </blockquote> [/COLOR] <blockquote class="postcontent restore " style="margin: 0px; padding: 0px; word-wrap: break-word;">ارسال عکس به دیتابیس(ذخیره عکس در دیتابیس) فکر نکنم نیاز به توضیح داشته باشه . كد: HTML: 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); }</blockquote> <blockquote class="signature restore" style="margin: 1em 0px 0px; padding: 1em 10px 0px; border-top: 1px solid rgb(233, 233, 233);"> <br class="Apple-interchange-newline"> </blockquote> <blockquote class="postcontent restore " style="margin: 0px; padding: 0px; word-wrap: break-word;">حذف رکوردهای انتخاب شده در DataGridView ما می خواهیم رکوردهایی که در dataGrideView انتخاب شده است را پاک کنیم (DataGrideiew متصل به یک DataTable) كد: HTML: DataGridViewSelectedRowCollection q = dataGridView1.SelectedRows; for (int i = 0; i < q.Count; i++) ** dt.Rows.Remove(dt.Rows.Find(q[i].Cells[0].Value)); } </blockquote> <blockquote class="signature restore" style="margin: 1em 0px 0px; padding: 1em 10px 0px; border-top: 1px solid rgb(233, 233, 233);"> <br class="Apple-interchange-newline"> </blockquote> ارسال: #6 RE:كدهاي به درد بخور سي شارپ ذخیره عکس با فرمتهای مختلف كد: HTML: //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); } } پرینت فایل متنی با استفاده از این کدها شما میتوانید فایلهای متنی رو بدون تصاویر پرینت بگیرید كد: HTML: 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; باز و بسته كردن در سي دي رام كد: HTML: 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);[/HTML[/LEFT] [/FONT][/COLOR][/COLOR] [COLOR=#000000][COLOR=#666666][FONT=tahoma]با استفاه از این کد شما می تونید یک عکس رو به اندازه یک دصد دلخواه تغییر اندازه بدین [LEFT]كد: [HTML]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; ** حرکت بین کنترلها با زدن کلید Enter در رویدادKeypress در هر کنترل کد زیر رو قرار بدین. كد: HTML: if( e.Keychar == 13) NextControl.Focus(); و اگر می خواهید کنترل به کنترلی مثل لیبل حرکت نکنه می تونید بجا nextcontrol نام کنترل رو قرار بدین مثل : كد: HTML: textbox1.focus();
كدهاي به درد بخور سي شارپ ارسال عكس به ديتا بيس كد: HTML: 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); ** به دست آوردن آدرسهای تایپ شده در اینترنت اکسپلورر ابتدا NameSpace هاي زير را وارد مي كنيم كد: HTML: using System.Collections.Generic; using Microsoft.Win32; سپس تابع زير را استفاده مي كنيم كد: HTML: public List<string> PopulateUrlList() ** //list the main registry key to open String regKey = "Software\\Microsoft\\Internet Explorer\\TypedURLs"; RegistryKey subKey = Registry.CurrentUser.OpenSubKey(regKey); String url; //create a list to hold our URL's List<string> urlList = new List<string>(); int counter = 1; while (true) ** //grab the current value, in the registry the key name //is url1, url2, url3, etc, while the value is the //actual url String sValName = "url" + counter.ToString(); url = (String)subKey.GetValue(sValName); if ((object)url == null) break; urlList.Add(url); counter++; ** return urlList; ** قراردادن متن بر روی عکس ( Watermark) ابتدا با دستور زیر عک عکس را لود می کنیم HTML: string fileloc = oFileDlg.FileName; //load image to picturebox pictureBox1.Image = Image.FromFile(fileloc); كد: سپس کد زیر را در یک رویداد قرار می دهیم كد: HTML: if (pictureBox1.Image != null) ** // Create image. Image tmp = pictureBox1.Image; // Create graphics object for alteration. Graphics g = Graphics.FromImage(tmp); // Create string to draw. String wmString = "Mdi Sample"; // Create font and brush. Font wmFont = new Font("Trebuchet MS", 10); SolidBrush wmBrush = new SolidBrush(Color.White); // Create point for upper-left corner of drawing. PointF wmPoint = new PointF(10.0F, 10.0F); // Draw string to image. g.DrawString(wmString, wmFont, wmBrush, wmPoint); //Load the new image to picturebox pictureBox1.Image = tmp; // Release graphics object. g.Dispose(); ** جستجو یک رشته در یک فایل متنی كد: HTML: bool searchtextfile(string fileadd, string regMatch) ** bool find = false; StreamReader testTxt = new StreamReader(fileadd); string allRead = testTxt.ReadToEnd(); testTxt.Close(); if (Regex.IsMatch(allRead, regMatch)) ** find = true; } else ** find = false; } }[/HTML [COLOR=#000000][COLOR=#666666][FONT=tahoma][B]خالی کردن کش اینترنت اکسپلورر(emety cach folder)[/B] [LEFT]كد: [HTML] 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; }[/HTML[/LEFT] [/FONT][/COLOR][/COLOR][B]كدهاي به درد بخور سي شارپ [/B] [COLOR=#000000][COLOR=#666666][FONT=tahoma][I][COLOR=teal][FONT=Tahoma]// array of integers to hold values[/FONT][/COLOR][/I] [COLOR=#0600ff][FONT=Tahoma]private[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]int[/COLOR][COLOR=black][][/COLOR] a = [COLOR=#0600ff]new[/COLOR] [COLOR=#0600ff]int[/COLOR][COLOR=black][[/COLOR][COLOR=red]100[/COLOR][COLOR=black]][/COLOR];[/FONT] [COLOR=#0600ff][FONT=Tahoma]private[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]int[/COLOR][COLOR=black][][/COLOR] b = [COLOR=#0600ff]new[/COLOR] [COLOR=#0600ff]int[/COLOR][COLOR=black][[/COLOR][COLOR=red]100[/COLOR][COLOR=black]][/COLOR];[/FONT] [I][COLOR=teal][FONT=Tahoma]// number of elements in array[/FONT][/COLOR][/I] [COLOR=#0600ff][FONT=Tahoma]private[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]int[/COLOR] x;[/FONT] [I][COLOR=teal][FONT=Tahoma]// Merge Sort Algorithm[/FONT][/COLOR][/I] [COLOR=#0600ff][FONT=Tahoma]public[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]void[/COLOR] sortArray[COLOR=black]()[/COLOR][/FONT] [COLOR=black][FONT=Tahoma]**[/FONT][/COLOR] [FONT=Tahoma]m_sort[COLOR=black]([/COLOR] [COLOR=red]0[/COLOR], x[COLOR=red]-1[/COLOR] [COLOR=black])[/COLOR];[/FONT] [COLOR=black][FONT=Tahoma]}[/FONT][/COLOR] [COLOR=#0600ff][FONT=Tahoma]public[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]void[/COLOR] m_sort[COLOR=black]([/COLOR] [COLOR=#0600ff]int[/COLOR] left, [COLOR=#0600ff]int[/COLOR] right [COLOR=black])[/COLOR][/FONT] [COLOR=black][FONT=Tahoma]**[/FONT][/COLOR] [FONT=Tahoma][COLOR=#0600ff]int[/COLOR] mid;[/FONT] [FONT=Tahoma][COLOR=#0600ff]if[/COLOR][COLOR=black]([/COLOR] right > left [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]mid = [COLOR=black]([/COLOR] right + left [COLOR=black])[/COLOR] / [COLOR=red]2[/COLOR];[/FONT] [FONT=Tahoma]m_sort[COLOR=black]([/COLOR] left, mid [COLOR=black])[/COLOR];[/FONT] [FONT=Tahoma]m_sort[COLOR=black]([/COLOR] mid[COLOR=red]+1[/COLOR], right [COLOR=black])[/COLOR];[/FONT] [FONT=Tahoma]merge[COLOR=black]([/COLOR] left, mid[COLOR=red]+1[/COLOR], right [COLOR=black])[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [COLOR=black][FONT=Tahoma]}[/FONT][/COLOR] [COLOR=#0600ff][FONT=Tahoma]public[/FONT][/COLOR][FONT=Tahoma] [COLOR=#0600ff]void[/COLOR] merge[COLOR=black]([/COLOR] [COLOR=#0600ff]int[/COLOR] left, [COLOR=#0600ff]int[/COLOR] mid, [COLOR=#0600ff]int[/COLOR] right [COLOR=black])[/COLOR][/FONT] [COLOR=black][FONT=Tahoma]**[/FONT][/COLOR] [FONT=Tahoma][COLOR=#0600ff]int[/COLOR] i, left_end, num_elements, tmp_pos;[/FONT] [FONT=Tahoma]left_end = mid - [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma]tmp_pos = left;[/FONT] [FONT=Tahoma]num_elements = right - left + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=#0600ff]while[/COLOR][COLOR=black]([/COLOR] [COLOR=black]([/COLOR]left <= left_end[COLOR=black])[/COLOR] && [COLOR=black]([/COLOR]mid <= right[COLOR=black])[/COLOR] [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma][COLOR=#0600ff]if[/COLOR][COLOR=black]([/COLOR] a[COLOR=black][[/COLOR]left[COLOR=black]][/COLOR] <= a[COLOR=black][[/COLOR]mid[COLOR=black]][/COLOR] [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]b[COLOR=black][[/COLOR]tmp_pos[COLOR=black]][/COLOR] = a[COLOR=black][[/COLOR]left[COLOR=black]][/COLOR];[/FONT] [FONT=Tahoma]tmp_pos = tmp_pos + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma]left = left [COLOR=red]+1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [FONT=Tahoma][COLOR=#0600ff]else[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]b[COLOR=black][[/COLOR]tmp_pos[COLOR=black]][/COLOR] = a[COLOR=black][[/COLOR]mid[COLOR=black]][/COLOR];[/FONT] [FONT=Tahoma]tmp_pos = tmp_pos + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma]mid = mid + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [FONT=Tahoma][COLOR=#0600ff]while[/COLOR][COLOR=black]([/COLOR] left <= left_end [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]b[COLOR=black][[/COLOR]tmp_pos[COLOR=black]][/COLOR] = a[COLOR=black][[/COLOR]left[COLOR=black]][/COLOR];[/FONT] [FONT=Tahoma]left = left + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma]tmp_pos = tmp_pos + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [FONT=Tahoma][COLOR=#0600ff]while[/COLOR][COLOR=black]([/COLOR] mid <= right [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]b[COLOR=black][[/COLOR]tmp_pos[COLOR=black]][/COLOR] = a[COLOR=black][[/COLOR]mid[COLOR=black]][/COLOR];[/FONT] [FONT=Tahoma]mid = mid + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma]tmp_pos = tmp_pos + [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [FONT=Tahoma][COLOR=#0600ff]for[/COLOR][COLOR=black]([/COLOR] i = [COLOR=red]0[/COLOR]; i < num_elements; i++ [COLOR=black])[/COLOR][/FONT] [FONT=Tahoma][COLOR=black]**[/COLOR][/FONT] [FONT=Tahoma]a[COLOR=black][[/COLOR]right[COLOR=black]][/COLOR] = b[COLOR=black][[/COLOR]right[COLOR=black]][/COLOR];[/FONT] [FONT=Tahoma]right = right - [COLOR=red]1[/COLOR];[/FONT] [FONT=Tahoma][COLOR=black]}[/COLOR][/FONT] [COLOR=black][FONT=Tahoma]} [/FONT][/COLOR][/FONT][/COLOR][/COLOR] [COLOR=#000000][COLOR=#666666][FONT=tahoma][B]شمارش تعداد تکرار یک کلمه در رشته[/B] [LEFT]كد: [HTML] int GetFreq(string word) ** string st = null; st = 'StringThatContainWord'; int start = 0, count = 0, curr = 0; int last = st.LastIndexOf(word); do ** curr = st.IndexOf(word, start); if (curr != -1) ** count++; start = curr + 1; } } while (last != curr); return count; } دریافت یک آرگمان ورودی در حالت Command Get command line arguments با استفاده از این کد شما می توانید در هنگام اجرای برنامه با آن مقدار اولیه بدهید كد: HTML: public static void Main(string[] args) ** if (args.Length > 0) ** System.Console.WriteLine(args[0]); try ** // long number = Int64.Parse(args[0]); // long number = Convert.ToInt64(s); long number = long.Parse(args[0]); System.Console.WriteLine("Number = " + number); } catch (System.FormatException e) ** System.Console.WriteLine("FormatException" + e); } return; } System.Console.WriteLine("Please enter a number"); } به دست آوردن اندازه تصویر Retrieve the current screen resolution برای به دست آوردن اندازه تصویر مانیتور اصلی كد: HTML: MessageBox.Show("Monitor Size:" + SystemInformation.PrimaryMonitorSize); [/LEFT] [/FONT][/COLOR][/COLOR]
و برای به دست آوردن اندازه تصویر مجازی كد: HTML: MessageBox.Show("VirtualScreen: " + SystemInformation.VirtualScreen); [/HTML [COLOR=#000000][COLOR=#666666][FONT=tahoma][B]تابعی برای رمز نگاری یکطرفه به وسیله الگوریتم md5[/B] [FONT=Tahoma]الگوریتم یکطرفه یعنی اینکه مقداری که به دست می آید قابل برگشت نیست......![/FONT] [FONT=Tahoma]اما مقداری که از یک رشته تولید می شود همیشه یکسان است.و می توان با مقایسه رشته رمز نگاری شده قبل و جدید اعتبار آن را تعیین کرد[/FONT] [LEFT][FONT=Tahoma]كد: [HTML]byte[] computemd5(string st1) ** MD5CryptoServiceProvider md51 = new MD5CryptoServiceProvider(); UTF8Encoding encode = new UTF8Encoding(); byte[] stbytes = encode.GetBytes(st1); byte[] result = md51.ComputeHash(stbytes); return result; } [/FONT] اجرای فقط یک کپی از برنامه این دستور چک می کند اگر هیچ برنامه ای از نوع برنامه فراخوانی شده در حال اجرا نباشد ، برنامه اجرا می شود. HTML: using System; using System.Collections.Generic; using System.Windows.Forms; using System.Diagnostics; namespace SingleInstanceTest ** static class Program ** [System.Runtime.InteropServices.DllImport("user32.d ll")] [return: System.Runtime.InteropServices.MarshalAs(System.Ru ntime.InteropServices.UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd); public static bool HasPriorInstance() ** Process currentProcess = Process.GetCurrentProcess(); string fileName = currentProcess.StartInfo.FileName; foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessN ame)) ** if (process.Id == currentProcess.Id) ** continue; } if (process.StartInfo.FileName != fileName) ** continue; } SetForegroundWindow(process.MainWindowHandle); return true; } return false; } [STAThread] static void Main() ** if (!HasPriorInstance()) ** Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(fals e); Application.Run(new Form1()); } } } }[/HTML ][/FONT][/COLOR][/COLOR] [/LEFT] [/FONT][/COLOR][/COLOR]
ارسال ایمیل بوسیله ی vb</acronym>.net سورس ارسال ایمیل بوسیله ی vb</acronym>.net , #C HTML: //************************************** // // Name: Sending email using DNS server // Description:Sometimes sending mails u // sing an SMTP server is not feasible for // a project’s requirement. We may wa // nt to utilize the MX record of the recip // ient’s domain name. The following // technical tip shows how to send mails us // ing mail servers of recipient’s do // main. We will be using Aspose.Network fo // r doing this. // By: aspose_seo // // Assumes:We used Aspose.Network for Se // nding email using DNS server. // //This code is copyrighted and has // limited warranties.Please see http:// // http://www.Planet-Source-Code.com/<acronym title="vBulletin" style="border-width: 0px 0px 1px; font-variant: normal; border-bottom: 1px dotted rgb(0, 0, 0); cursor: help;">vb</acronym>/scripts/Sh // owCode.asp?txtCodeId=7114&lngWId=10 //for details. //************************************** // [C#] MailMessage msg = new MailMessage(); msg.From = "sender@mail.com"; msg.To = "use1@mail.com;user2@mail.com"; msg.Subject = "dns sending"; msg.Body = "it is a test."; DnsMailClient client = new DnsMailClient(); client.Send(msg); [VB</acronym>.NET] Dim msg As MailMessage = New MailMessage() msg.From = "sender@mail.com" msg.To = "use1@mail.com;user2@mail.com" msg.Subject = "dns sending" msg.Body = "it is a test. Dim client As DnsMailClient = New DnsMailClient() client.Send(msg) کانورت انواع فرمت ها به PDF در vb</acronym>.net convert an Excel XLS file to PDF دانلود سورس کانورت انواع فرمت ها به PDF در vb</acronym>.net HTML: //************************************** // // Name: aspose_seo // Description:This technical tip shows // how to convert an Excel XLS file to PDF // even if it contains any images or charts // within it. // By: aspose_seo // // Assumes:This technical tip shows how // to convert an Excel XLS file to PDF even // if it contains any images or charts with // in it. You will be using Aspose.Cells an // d Aspose.Pdf libraries for XLS2PDF conve // rsion. Please also make sure to save you // r Aspose.Pdf XML file on disk, not in a // stream because Aspose.Pdf XML file is be // ing used as a medium to preserve those i // mage files. // //This code is copyrighted and has // limited warranties.Please see http:// // http://www.Planet-Source-Code.com/<acronym title="vBulletin" style="border-width: 0px 0px 1px; font-variant: normal; border-bottom: 1px dotted rgb(0, 0, 0); cursor: help;">vb</acronym>/scripts/Sh // owCode.asp?txtCodeId=7113&lngWId=10 //for details. //************************************** // [C#] // Saving an XLS file in Aspose.Pdf xml // format Workbook wb = new Workbook(); wb.Open("C:\\book1.xls); wb.Save("C:\\xls2pdf.xml", FileFormatType.AsposePdf); // Converting XLS file to PDF through As // pose.Pdf using Aspose.Pdf xml file as a // medium Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf(); pdf.BindXML("c:\\xls2pdf.xml", null); pdf.Save("C:\\xls2pdf.pdf"); [VB</acronym>] ' Saving an XLS file in Aspose.Pdf xml format Dim wb as Workbook = new Workbook() wb.Open("C:\book1.xls) wb.Save("C:\xls2pdf.xml", FileFormatType.AsposePdf) ' Converting XLS file to PDF through Aspose.Pdf using Aspose.Pdf xml file as a medium Dim pdf as Aspose.Pdf.Pdf = new Aspose.Pdf.Pdf() pdf.BindXML("c:\\xls2pdf.xml", null) pdf.Save("C:\xls2pdf.pdf") یافتن کنترل به صورت بازگشتی با استفاده از این تابعشما می توانید کنترل مورد نظر در فرم را به صورت بازگشتی پیدا کنید كد: HTML: public Control FindControlRecursive(Control container, string name) ** if (container.ID == name) return container; foreach (Control ctrl in container.Controls) ** Control foundCtrl = FindControlRecursive(ctrl, name); if (foundCtrl != null) return foundCtrl; } return null; }