Socarsky
Well-known member
I am getting System.ArgumentException {"Parameter is not valid."} error after I try to input in raw of three DataGridView's cells.
I think the manipulation of DataGridView causes that error but I got that from MSDN.
Hope someone can notice what's the lack in the code.
I think the manipulation of DataGridView causes that error but I got that from MSDN.
Hope someone can notice what's the lack in the code.
Private Sub InitializeDataGridView() ' Initialize basic DataGridView properties. DataGridView1.Dock = DockStyle.Fill DataGridView1.BackgroundColor = Color.LightGray DataGridView1.BorderStyle = BorderStyle.Fixed3D ' Set property values appropriate for read-only display and ' limited interactivity. DataGridView1.AllowUserToAddRows = True DataGridView1.AllowUserToDeleteRows = True DataGridView1.AllowUserToOrderColumns = True 'DataGridView1.ReadOnly = False 'DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect DataGridView1.MultiSelect = True DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None DataGridView1.AllowUserToResizeColumns = True DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing DataGridView1.AllowUserToResizeRows = False DataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing ' Set the selection background color for all the cells. DataGridView1.DefaultCellStyle.SelectionBackColor = Color.White DataGridView1.DefaultCellStyle.SelectionForeColor = Color.Black ' Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default ' value won't override DataGridView.DefaultCellStyle.SelectionBackColor. DataGridView1.RowHeadersDefaultCellStyle.SelectionBackColor = Color.Empty ' Set the background color for all rows and for alternating rows. ' The value for alternating rows overrides the value for all rows. DataGridView1.RowsDefaultCellStyle.BackColor = Color.LightGray DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.DarkGray ' Set the row and column header styles. DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Black DataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.Black ' Set the Format property on the "Last Prepared" column to cause ' the DateTime to be formatted as "Month, Year". DataGridView1.Columns("Tarih").DefaultCellStyle.Format = "y" ' Specify a larger font for the "Ratings" column. Dim font As New Font( _ DataGridView1.DefaultCellStyle.Font.FontFamily, 14, FontStyle.Bold) Try DataGridView1.Columns("LastName").DefaultCellStyle.Font = font Finally font.Dispose() End Try End Sub
Last edited: