V
Vili
Hi all
Posted this to microsoft.public.dotnet.framework.windowsforms.controls,
but with no answers so I try here.
I have created a datagridview and a datasource at designmode and then
added two colums.
Second column is my own custom column with custom cell where I want to
insert object.
Problem is that on the CellFormatting event the e.ColumnIndex never
points to myCol -column. How can I get the cellformatting happen to
myCol?
I noticed that somehow when the CellFormatting event happens
DGV.Columns.Count is 1
and it should be 2. Lice my cell doesn't even exist
Here is some code
DGV.AutoGenerateColumns = False
Dim newColIndex As Integer = DGV.Columns.Add("ID", "ID")
DGV.Columns(newColIndex).DataPropertyName = "ID" 'Bound column
Dim col As New ControlColumn
col.Name = "myCol"
col.HeaderText = "myCol"
DGV.Columns.Add(col) 'Unbound custom column
'Here is my CellFormatting event with the problem
Private Sub DGV_CellFormatting(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellFormattingEventArgs)
Handles DGV.CellFormatting
If e.ColumnIndex = DGV.Columns("Oma").Index Then
e.FormattingApplied = True
dim oMyObject as new mycustomclass
'Setting up the object here...
e.Value = oMyobject
End If
End Sub
Posted this to microsoft.public.dotnet.framework.windowsforms.controls,
but with no answers so I try here.
I have created a datagridview and a datasource at designmode and then
added two colums.
Second column is my own custom column with custom cell where I want to
insert object.
Problem is that on the CellFormatting event the e.ColumnIndex never
points to myCol -column. How can I get the cellformatting happen to
myCol?
I noticed that somehow when the CellFormatting event happens
DGV.Columns.Count is 1
and it should be 2. Lice my cell doesn't even exist
Here is some code
DGV.AutoGenerateColumns = False
Dim newColIndex As Integer = DGV.Columns.Add("ID", "ID")
DGV.Columns(newColIndex).DataPropertyName = "ID" 'Bound column
Dim col As New ControlColumn
col.Name = "myCol"
col.HeaderText = "myCol"
DGV.Columns.Add(col) 'Unbound custom column
'Here is my CellFormatting event with the problem
Private Sub DGV_CellFormatting(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellFormattingEventArgs)
Handles DGV.CellFormatting
If e.ColumnIndex = DGV.Columns("Oma").Index Then
e.FormattingApplied = True
dim oMyObject as new mycustomclass
'Setting up the object here...
e.Value = oMyobject
End If
End Sub