Hi! I'm writing a statistical analysis program where I don't know, in advance, how many variables will be involved. I'm having the user enter data for each variable in a datagrid. First I ask for the number of variables. Based on that, I add as many new columns as needed. 2 is the minimum, so two columns are always present. 20 is the maximum.
The question is, how can I copy the default style of an existing column to the new column? I've tried a number of variations on
ColName = "X" & CStr(ColNum) & "LagColumn"
ColHeader = "X" & CStr(ColNum)
MultiLagGrid.Columns.Add(ColName, ColHeader)
LagStyle = New DataGridViewCellStyle
LagStyle = MultiLagGrid.Columns(1).DefaultCellStyle
MultiLagGrid.Columns(ColIndex).DefaultCellStyle.ApplyStyle(LagStyle)
These all compile. But every variation I try brings up a new and different unclear run-time error message. Help!