We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I cancel editing of one colum under certain conditions?

Thread ID:

Created:

Updated:

Platform:

Replies:

26736 Mar 31,2005 01:20 AM UTC Mar 31,2005 11:05 PM UTC Windows Forms 4
loading
Tags: GridControl
Damien Sawyer
Asked On March 31, 2005 01:20 AM UTC

Hi, I have a boundgrid with a datatable as the source. I wish to catch edits on one of the colums (the editable primary key) and block the change if records exist in child tables. The strange this is, in the following code, the gridboundcolumns collection is always returning zero records? Any suggestions? Thanks in advance, Damien Sawyer Private Sub gdItems_CurrentCellChanging(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles gdItems.CurrentCellChanging Dim i As Int16 = gdItems.GridBoundColumns.IndexOf(Me.gdItems.Binder.InternalColumns("ItemID")) If gdItems.CurrentCell.ColIndex = i Then MsgBox("Can''t Edit this cell") e.Cancel = True End If End Sub

Administrator [Syncfusion]
Replied On March 31, 2005 01:23 AM UTC

In a hierarchical GriddataBoundGrid, when you call grid.Binder.AddRelation to set up the hierarchies, the call returns a GridHierarchyLevel object. This object has a property, GridBoundColumns, and it is this collection that holds the GridBoundColumns used in the hierarchical GridDataBoundGrid.

Damien Sawyer
Replied On March 31, 2005 01:37 AM UTC

Thanks Clay, But I didn''t set up this grid as heirarchial... It''s just ''normal''... '' Bind the DataGrids to their datatables Me.gdItems.DataSource = p_dsItems.Tables("dtItems") thanks in advance, DS

Administrator [Syncfusion]
Replied On March 31, 2005 08:11 AM UTC

The grid.GridBoundColumnsCollection is only populated if you have explicitly added GridBoundColumns. If you have not added GridBoundColumns, then you always use the grid.Binder.InternalColumns collection, which should not be empty after its datasource has been set. Instead of
Dim i As Int16 = gdItems.GridBoundColumns.IndexOf(Me.gdItems.Binder.InternalColumns("ItemID"))
If gdItems.CurrentCell.ColIndex = i Then
    MsgBox("Can''''t Edit this cell")
    e.Cancel = True
End If
try
Dim i As Int16 = gdItems.Binder.NameToColIndex("ItemID")
If gdItems.CurrentCell.ColIndex = i Then
   MsgBox("Can''''t Edit this cell")
   e.Cancel = True
End If
Another options is to just set gdItems.Binder.InternalColumns("ItemID").StyleInfo.ReadOnly = True in Form.Load. If you never want a cell in the column to become teh currentcell, you can also set ").StyleInfo.Enabled = False. Or, you could set ").StyleInfo.CellType = "Static". This way you could do things by setting a property instead of handling an event.

Damien Sawyer
Replied On March 31, 2005 11:05 PM UTC

Fantastic Clay, Thanks for your help! :-) DS

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;