Forms









How do I use Forms
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: Form9.cs Copy
188         private void btnSinhVien_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
189         {
190             CloseForm("Form9");
191             FormSinhVien f = new FormSinhVien();
192             f.MdiParent = this;
193             f.Show();
194         }
File name: FormSinhVien.cs Copy
15         public FormSinhVien()
16         {
17             InitializeComponent();
18         }
File name: FormSinhVien.cs Copy
20         private void FormSinhVien_Load(object sender, EventArgs e)
21         {
22             // TODO: This line of code loads data into the 'cNPM_1DataSet6.Lop' table. You can move, or remove it, as needed.
23             this.lopTableAdapter.Fill(this.cNPM_1DataSet_Lop.Lop);
24             dgvSinhVien.DataSource = business.ShowData("SinhVien");
25         }
File name: FormSinhVien.cs Copy
37         private void btnThem_Click(object sender, EventArgs e)
38         {
39             if (txtMaSV.Text!="")
40             {
41                 if(business.Proc_Insert("Insert_SinhVien",txtMaSV.Text))
42                 {
43                     string sql = "'"+txtMaSV.Text+"','"+txtTenSV.Text+"','"+dtpNgaySinh.Text+"','"+txtDiaChi.Text+"','"+cmbMaLop.SelectedValue.ToString()+"'";
44                     business.Insert("SinhVien",sql);
45                     FormSinhVien_Load(sender,e);
46                 }
47                 else
48              {
49                     MessageBox.Show("Mã SV đã tồn tại");
50              }
51             }
52         }
File name: FormSinhVien.cs Copy
54         private void btnXoa_Click(object sender, EventArgs e)
55         {
56             DialogResult result;
57             result = MessageBox.Show("Bạn có chắc chắn muốn xóa không ?", "Hệ Thống", MessageBoxButtons.YesNo);
58             if (result == DialogResult.Yes)
59             {
60                 string sql = "MaSV='" + txtMaSV.Text + "'";
61                 business.Delete("SinhVien", sql);
62                 FormSinhVien_Load(sender, e);
63             }
64         }
File name: FormSinhVien.cs Copy
66         private void btnSua_Click(object sender, EventArgs e)
67         {
68             string sql = "TenSV='" + txtTenSV.Text + "',NgaySinh='" + dtpNgaySinh.Text + "',DiaChi='" + txtDiaChi.Text + "',MaLop='" + cmbMaLop.SelectedValue.ToString() +"' where MaSV='" + txtMaSV.Text + "'";
69             business.Update("SinhVien", sql);
70             FormSinhVien_Load(sender, e);
71         }
File name: PhotonHandler.cs Copy
59     protected void Update()
60     {
61         if (PhotonNetwork.networkingPeer == null)
62         {
63             Debug.LogError("NetworkPeer broke!");
64             return;
65         }
66
67         if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated || PhotonNetwork.connectionStateDetailed == PeerState.Disconnected || PhotonNetwork.offlineMode)
68         {
69             return;
70         }
71
72         // the messageQueue might be paused. in that case a thread will send acknowledgements only. nothing else to do here.
73         if (!PhotonNetwork.isMessageQueueRunning)
74         {
75             return;
76         }
77
78         bool doDispatch = true;
79         while (PhotonNetwork.isMessageQueueRunning && doDispatch)
80         {
81             // DispatchIncomingCommands() returns true of it found any command to dispatch (event, result or state change)
82             UnityEngine.Profiling.Profiler.BeginSample("DispatchIncomingCommands");
83             doDispatch = PhotonNetwork.networkingPeer.DispatchIncomingCommands();
84             UnityEngine.Profiling.Profiler.EndSample();
85         }
86
87         int currentMsSinceStart = (int)(Time.realtimeSinceStartup * 1000); // avoiding Environment.TickCount, which could be negative on long-running platforms
88         if (PhotonNetwork.isMessageQueueRunning && currentMsSinceStart > this.nextSendTickCountOnSerialize)
89         {
90             PhotonNetwork.networkingPeer.RunViewUpdate();
91             this.nextSendTickCountOnSerialize = currentMsSinceStart + this.updateIntervalOnSerialize;
92             this.nextSendTickCount = 0; // immediately send when synchronization code was running
93         }
94
95         currentMsSinceStart = (int)(Time.realtimeSinceStartup * 1000);
96         if (currentMsSinceStart > this.nextSendTickCount)
97         {
98             bool doSend = true;
99             while (PhotonNetwork.isMessageQueueRunning && doSend)
100             {
101                 // Send all outgoing commands
102                 UnityEngine.Profiling.Profiler.BeginSample("SendOutgoingCommands");
103                 doSend = PhotonNetwork.networkingPeer.SendOutgoingCommands();
104                 UnityEngine.Profiling.Profiler.EndSample();
105             }
106
107             this.nextSendTickCount = currentMsSinceStart + this.updateInterval;
108         }
109     }
File name: Form1.cs Copy
236   public void Button4_Click(System.Object sender, System.EventArgs e)
237   {
238
239    string strmessage = default(string);
240    DialogResult dgrResult;
241
242    strmessage = "Are you sure you want to save data?";
243    dgrResult = MessageBox.Show(strmessage, "Save data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
244
245
246    if (dgrResult == System.Windows.Forms.DialogResult.Yes)
247    {
248
249     newgrade = gradeclass.DataModule.SaveItem();
250    }
251
252   }
File name: Form1.cs Copy
373   public void Button11_Click(System.Object sender, System.EventArgs e)
374   {
375    string strmessage = default(string);
376    DialogResult dgrResult;
377
378    strmessage = "Are you sure you want to Delete this record?";
379    dgrResult = MessageBox.Show(strmessage, "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
380
381
382    if (dgrResult == System.Windows.Forms.DialogResult.Yes)
383    {
384
385     dsgrade = gradeclass.DataModule.deldata();
386
387    }
388
389
390
391   }
File name: Form1.cs Copy
397   public void DataGridView1_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
398   {
399    TextBox1.Text = DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
400    TextBox2.Text = DataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
401    TextBox3.Text = DataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
402    TextBox4.Text = DataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
403    TextBox5.Text = DataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
404    TextBox6.Text = DataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
405    TextBox7.Text = DataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
406    TextBox8.Text = DataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
407    TextBox9.Text = DataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
408    TextBox10.Text = DataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
409    TextBox11.Text = DataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString();
410    TextBox12.Text = DataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
411    TextBox13.Text = DataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
412    TextBox14.Text = DataGridView1.Rows[e.RowIndex].Cells[14].Value.ToString();
413    TextBox15.Text = DataGridView1.Rows[e.RowIndex].Cells[15].Value.ToString();
414    TextBox16.Text = DataGridView1.Rows[e.RowIndex].Cells[16].Value.ToString();
415    TextBox17.Text = DataGridView1.Rows[e.RowIndex].Cells[17].Value.ToString();
416    TextBox18.Text = DataGridView1.Rows[e.RowIndex].Cells[18].Value.ToString();
417    TextBox19.Text = DataGridView1.Rows[e.RowIndex].Cells[19].Value.ToString();
418    STUDID.Text = DataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
419
420
421   }

Download file with original file name:Forms

Forms 118 lượt xem

Gõ tìm kiếm nhanh...