コード例 #1
0
        private void metroTile5_Click(object sender, EventArgs e)
        {
            Edit_lec_details b = new Edit_lec_details();

            b.no = lbl_lec_no.Text;
            b.Show();
        }
コード例 #2
0
 private void metroGrid1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         var senderGrid = (DataGridView)sender;
         if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
             e.RowIndex >= 0 && senderGrid.Columns[e.ColumnIndex].HeaderText == "View Lecturer Profile")
         {
             string   no       = metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString();
             string   name     = metroGrid1.Rows[e.RowIndex].Cells[2].Value.ToString();
             string[] allFiles = System.IO.Directory.GetFiles("C:\\Users\\94762\\Desktop\\lecs");
             foreach (string file in allFiles)
             {
                 string[] n = file.Split('_');
                 if (file.Contains(metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString()) && file.Contains("docx"))
                 {
                     Microsoft.Office.Interop.Word.Application ap = new Microsoft.Office.Interop.Word.Application();
                     Document document = ap.Documents.Open(file);
                 }
             }
         }
         else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                  e.RowIndex >= 0 && senderGrid.Columns[e.ColumnIndex].HeaderText == "Edit Lecturers details")
         {
             //Edit_lec_details.no = metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString();
             Edit_lec_details p = new Edit_lec_details();
             p.Show();
         }
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("wef");
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         MessageBox.Show(this, "File not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }