P
Peter Proost
Hi group I'm making my own datagrid control, so for I've got a lot of things
working, combobox columns, checkbox columns, blobfield columns. But now I
would like to be able the disable certain columns for editing I know I can
use readonly for the columnstyle but this will also disallow me to edit the
cell when I add a new row.
So I was thinking of using the overrides sub Edit in my class which inherits
from DataGridTextBoxColumn
and then check if the current rownumber is smaller then the total number of
rownumbers, if it is true, disable editing else enable it. Now I was just
wondering if this is the best way to do it.
Private intAantalRijen as Integer
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal _ rowNum As Integer, ByVal
bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal _
instantText As String, ByVal cellIsVisible As Boolean)
If TypeOf (Me.DataGridTableStyle.DataGrid.DataSource) Is DataTable
Then
intAantalRijen =
DirectCast(Me.DataGridTableStyle.DataGrid.DataSource, DataTable).Rows.Count
End If
If rowNum = intAantalRijen Then
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText,
cellIsVisible)
End If
End Sub
Greetz Peter
working, combobox columns, checkbox columns, blobfield columns. But now I
would like to be able the disable certain columns for editing I know I can
use readonly for the columnstyle but this will also disallow me to edit the
cell when I add a new row.
So I was thinking of using the overrides sub Edit in my class which inherits
from DataGridTextBoxColumn
and then check if the current rownumber is smaller then the total number of
rownumbers, if it is true, disable editing else enable it. Now I was just
wondering if this is the best way to do it.
Private intAantalRijen as Integer
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal _ rowNum As Integer, ByVal
bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal _
instantText As String, ByVal cellIsVisible As Boolean)
If TypeOf (Me.DataGridTableStyle.DataGrid.DataSource) Is DataTable
Then
intAantalRijen =
DirectCast(Me.DataGridTableStyle.DataGrid.DataSource, DataTable).Rows.Count
End If
If rowNum = intAantalRijen Then
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText,
cellIsVisible)
End If
End Sub
Greetz Peter