1

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!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by bpl1960
0

>how can I copy the default style of an existing column to the new column?

Clone() method.

LagStyle = MultiLagGrid.Columns(1).DefaultCellStyle.Clone()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.