/// <summary> /// Create a DataGridView according by a Location and Name /// </summary> /// <param name="location">Locate of DataGridView in Client Panel's</param> /// <param name="Name">Name of DataGridView</param> /// <returns>Created DataGridView's</returns> private DataGridView Standard_dgv(Point location, string Name) { DataGridView dgv = new DataGridView(); DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle10 = new DataGridViewCellStyle(); dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleCenter; DataGridViewTextBoxColumnEx TimeSpans = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx SAT = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx SUN = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx MON = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx TUE = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx WED = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx THUR = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx FRI = new DataGridViewTextBoxColumnEx(); #region DataGridViewTextBoxColumnEx TimeSpans dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle2.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); TimeSpans.DefaultCellStyle = dataGridViewCellStyle2; TimeSpans.Frozen = true; TimeSpans.HeaderText = "Time Span"; TimeSpans.Name = "TimeSpan"; TimeSpans.ReadOnly = true; TimeSpans.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; TimeSpans.ToolTipText = "Class Time in Days"; #endregion #region DataGridViewTextBoxColumnEx SAT SAT.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; SAT.DefaultCellStyle = dataGridViewCellStyle3; SAT.FillWeight = 90F; SAT.HeaderText = "SAT"; SAT.Name = "SAT"; SAT.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx SUN SUN.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; SUN.DefaultCellStyle = dataGridViewCellStyle3; SUN.FillWeight = 90F; SUN.HeaderText = "SUN"; SUN.Name = "SUN"; SUN.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx MON MON.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; MON.DefaultCellStyle = dataGridViewCellStyle3; MON.FillWeight = 90F; MON.HeaderText = "MON"; MON.Name = "MON"; MON.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx TUE TUE.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; TUE.DefaultCellStyle = dataGridViewCellStyle3; TUE.FillWeight = 90F; TUE.HeaderText = "TUE"; TUE.Name = "TUE"; TUE.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx WED WED.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; WED.DefaultCellStyle = dataGridViewCellStyle3; WED.FillWeight = 90F; WED.HeaderText = "WED"; WED.Name = "WED"; WED.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx THUR THUR.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; THUR.DefaultCellStyle = dataGridViewCellStyle3; THUR.FillWeight = 90F; THUR.HeaderText = "THUR"; THUR.Name = "THUR"; THUR.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion #region DataGridViewTextBoxColumnEx FRI FRI.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; FRI.DefaultCellStyle = dataGridViewCellStyle3; FRI.FillWeight = 90F; FRI.HeaderText = "FRI"; FRI.Name = "FRI"; FRI.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; #endregion // // Set Data for DataGridView dgv // #region Define DataGridView dgv Body's dgv.AllowUserToAddRows = false; dgv.AllowUserToDeleteRows = false; dgv.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); dgv.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; dgv.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Sunken; dgv.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Sunken; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle1.Font = new System.Drawing.Font("Times New Roman", 11.5F); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dgv.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; dgv.ColumnHeadersHeight = 40; dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { TimeSpans, SAT, SUN, MON, TUE, WED, THUR, FRI}); dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178))); dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.ControlText; dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dgv.DefaultCellStyle = dataGridViewCellStyle10; dgv.GridColor = System.Drawing.SystemColors.ActiveCaption; dgv.Location = location; dgv.Name = Name; dgv.RightToLeft = System.Windows.Forms.RightToLeft.No; dgv.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Sunken; dgv.RowHeadersVisible = false; dgv.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; dgv.RowTemplate.Height = 35; dgv.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; dgv.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; dgv.Size = new System.Drawing.Size(748, 462); dgv.ReadOnly = true; dgv.RightToLeft = (CultureInfo.CurrentCulture.EnglishName == "Persian" || CultureInfo.CurrentCulture.EnglishName == "Farsi") ? System.Windows.Forms.RightToLeft.Yes : System.Windows.Forms.RightToLeft.No; dgv.MultiSelect = false; #endregion // // Add TimeSlots Data (8 - 9 , 9 - 10 , 10 - 11 , ... , 19 - 20) // for (int i = 8; i < 20; i++) { dgv.Rows.Add(i.ToString() + " - " + (i + 1).ToString()); } // // Clear any Selected dgv.ClearSelection(); // // End return dgv; }
private DataGridView Standard_dgv(Point location, string Name) { DataGridView dgv = new DataGridView(); DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle(); DataGridViewCellStyle dataGridViewCellStyle10 = new DataGridViewCellStyle(); dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleCenter; DataGridViewTextBoxColumnEx TimeSpans = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx SAT = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx SUN = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx MON = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx TUE = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx WED = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx THUR = new DataGridViewTextBoxColumnEx(); DataGridViewTextBoxColumnEx FRI = new DataGridViewTextBoxColumnEx(); // // TimeSpans // dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle2.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); TimeSpans.DefaultCellStyle = dataGridViewCellStyle2; TimeSpans.Frozen = true; TimeSpans.HeaderText = "Time Span"; TimeSpans.Name = "TimeSpan"; TimeSpans.ReadOnly = true; TimeSpans.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; TimeSpans.ToolTipText = "Class Time in Days"; // // SAT // SAT.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; SAT.DefaultCellStyle = dataGridViewCellStyle3; SAT.FillWeight = 90F; SAT.HeaderText = "SAT"; SAT.Name = "SAT"; SAT.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // SUN // SUN.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; SUN.DefaultCellStyle = dataGridViewCellStyle3; SUN.FillWeight = 90F; SUN.HeaderText = "SUN"; SUN.Name = "SUN"; SUN.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // MON // MON.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; MON.DefaultCellStyle = dataGridViewCellStyle3; MON.FillWeight = 90F; MON.HeaderText = "MON"; MON.Name = "MON"; MON.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // TUE // TUE.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; TUE.DefaultCellStyle = dataGridViewCellStyle3; TUE.FillWeight = 90F; TUE.HeaderText = "TUE"; TUE.Name = "TUE"; TUE.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // WED // WED.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; WED.DefaultCellStyle = dataGridViewCellStyle3; WED.FillWeight = 90F; WED.HeaderText = "WED"; WED.Name = "WED"; WED.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // THUR // THUR.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; THUR.DefaultCellStyle = dataGridViewCellStyle3; THUR.FillWeight = 90F; THUR.HeaderText = "THUR"; THUR.Name = "THUR"; THUR.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // FRI // FRI.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; FRI.DefaultCellStyle = dataGridViewCellStyle3; FRI.FillWeight = 90F; FRI.HeaderText = "FRI"; FRI.Name = "FRI"; FRI.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // dgv // dgv.AllowUserToAddRows = false; dgv.AllowUserToDeleteRows = false; dgv.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); dgv.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; dgv.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Sunken; dgv.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Sunken; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle1.Font = new System.Drawing.Font("Times New Roman", 11.5F); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dgv.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; dgv.ColumnHeadersHeight = 40; dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { TimeSpans, SAT, SUN, MON, TUE, WED, THUR, FRI }); dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Window; dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178))); dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.ControlText; dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dgv.DefaultCellStyle = dataGridViewCellStyle10; dgv.GridColor = System.Drawing.SystemColors.ActiveCaption; dgv.Location = location; dgv.Name = Name; dgv.RightToLeft = System.Windows.Forms.RightToLeft.No; dgv.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Sunken; dgv.RowHeadersVisible = false; dgv.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; dgv.RowTemplate.Height = 35; dgv.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; dgv.CausesValidation = true; dgv.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect; dgv.Size = new System.Drawing.Size(748, 462); dgv.ReadOnly = true; dgv.RightToLeft = (CultureInfo.CurrentCulture.EnglishName == "Persian" || CultureInfo.CurrentCulture.EnglishName == "Farsi") ? System.Windows.Forms.RightToLeft.Yes : System.Windows.Forms.RightToLeft.No; dgv.CellContentClick += new DataGridViewCellEventHandler(dgv_CellContentClick); dgv.CellMouseUp += new DataGridViewCellMouseEventHandler(dgv_CellMouseUp); dgv.MultiSelect = false; // // Add TimeSlots Data // for (int i = 8; i < 20; i++) { dgv.Rows.Add(i.ToString() + " - " + (i + 1).ToString()); } // return(dgv); }