Post by Goborijung at 2020-09-12 09:06:31 | ID: 779
dg.Rows.Clear(); dg.Refresh();
Post by Goborijung at 2020-08-29 14:58:35 | ID: 679
// Close Application ปิดแค่หน้าปัจจุบันหน้าเดียว int num = 365; string str = $"Close This Page {num} ?"; if (MessageBox.Show(str, "ปิดหน้านี้", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Close(); }
// Close Application ปิดทุกๆหน้า (ปิดโปรแกรมทิ้งไปเลยจ้าาา) int num = 365; string str = $"Exit application {num} ?"; if (MessageBox.Show(str, "ปิดโปรแกรม", MessageBoxButtons.YesNo) == DialogResult.Yes) { Application.Exit(); }
Post by Goborijung at 2020-10-24 00:39:21 | ID: 849
if (obj.showConfirm("Confirm Update?") == true) { // }
Post by Goborijung at 2023-05-30 19:05:02 | ID: 1917
Ref: https://www.connectionstrings.com/sql-server/
Post by Goborijung at 2020-09-23 03:01:07 | ID: 768
public string md5(string password) { StringBuilder hash = new StringBuilder(); MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider(); byte[] bytes = md5provider.ComputeHash(new UTF8Encoding().GetBytes(password)); for (int i = 0; i < bytes.Length; i++) { hash.Append(bytes[i].ToString("x2")); } return hash.ToString(); }
>> การใช้งาน string hash = md5("password");
>> การใช้งานผ่าน Class objAction string hash = new objAction().md5("password");
Post by Goborijung at 2020-10-19 14:48:59 | ID: 845
>> Create RowNumber And Set Columns is Center // Set RowNumber SELECT ROW_NUMBER() OVER(ORDER BY b.No_ ASC) AS # // Set Columns With And Text Center cTool.textWidth(dgMain,0,30); cTool.textCenter(dgMain,0); // Set Columns Color foreach(DataGridViewRow r in dgTransferDetail.Rows) { r.Cells["Transfer"].Style.BackColor = Color.LightBlue; }
Post by Goborijung at 2020-09-25 14:28:13 | ID: 826
// How to Create Listview and Add Data to Listview
// Add to List
private void btnAddToList_Click(object sender, EventArgs e) { /* กำหนดค่าให้กับ Listview */ listView1.View = View.Details; listView1.GridLines = true; listView1.FullRowSelect = true; //Add items in the listview สร้าง Array Item ที่จะเพิ่มเข้าไปใน Listview string[] arr = new string[4]; ListViewItem lvi; foreach(DataGridViewRow row in dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells["checkBoxColumn"].Value) == true) { /* Add Item เข้า Array */ arr[0] = row.Cells["OID"].Value.ToString(); arr[1] = row.Cells["FullName"].Value.ToString(); arr[2] = row.Cells["Password"].Value.ToString(); /* โยน Array เข้าไปใน ListviewItem */ lvi = new ListViewItem(arr); /* เพิ่ม ListviewItem เข้าไปในกล่อง Listview */ listView1.Items.Add(lvi); } } }// ClearList
private void btnClearList_Click(object sender, EventArgs e) { listView1.Items.Clear(); }// RemoveList
private void btnRemoveList_Click(object sender, EventArgs e) { try { listView1.Items.Remove(listView1.SelectedItems[0]); } catch {} }
Post by Goborijung at 2020-09-14 11:46:50 | ID: 796
private Form activeForm = null; private void openChildForm(Form childForm) { if (activeForm != null) activeForm.Close(); activeForm = childForm; childForm.TopLevel = false; childForm.FormBorderStyle = FormBorderStyle.None; childForm.Dock = DockStyle.Fill; panelMain.Controls.Add(childForm); panelMain.Tag = childForm; childForm.BringToFront(); childForm.Show(); } >> การใช้งาน openChildForm(new About());
Post by Goborijung at 2020-11-30 13:34:54 | ID: 898
http://thinkofdev.com/auto-increase-project-version-number-in-visual-studio/
Post by Goborijung at 2020-11-18 13:37:34 | ID: 885
ref: https://www.c-sharpcorner.com/UploadFile/1e050f/creating-and-using-dll-class-library-in-C-Sharp/// การสร้างไฟล์ myClass.dll
1. Create New Project > Use Class Library (.Net for Window) 2. สร้าง Class ใหม่เข้าไปในไฟล์ (อย่าให้ซ้ำกับชื่อไฟล์) - สร้าง Function เข้าไปในแต่ละ Class 3. หลังจากสร้างเสร็จแล้วให้ทำการ Buid Solution 4. จะได้ไฟล์ .dll ที่ bin/Debug// การนำ Class dll ไปใช้งาน
1. Add Reference เข้ามาใช้งานใน Project 2. หลังจาก Add Reference เข้ามาาเรียบร้อยแล้วให้ทำการ using ชื่อไฟล์เข้ามา using myClass; 3. //Global Variable ให้ทำการสร้างเป็น New Class ขึ้นมา// ตัวอย่างการใช้งาน Class dll
// Global Variable myClass mc = new myClass(); m.functionName();