Search code examples
vb.netvisual-studio-2013gridex

How do I change the Column.EditType property on an unbound Janus GridEx Row (v3) at runtime


Good afternoon,

I am missing something somewhere and I am in need of help.

What I am trying to do is change the EditType of a checkbox column for a GridEx row that I am adding at runtime. The code I have at the moment is as follows:

Private Sub FillGroupGrid(asset as AssetDetail)
    Dim row As GridEXRow = jgrdGroup.AddItem()

    row.BeginEdit()

    row.Cells(COL_NAME_GROUP_ID).Value = asset.GroupID
    row.Cells(COL_NAME_NAME).Value = asset.Name

    row.Cells(COL_NAME_SELECTED).Column.EditType = IIf(asset.InUse, EditType.NoEdit, EditType.CheckBox)
    row.IsChecked = asset.Selected

    row.EndEdit()
End Sub

The rows are added without a problem, but the edit type of the checkbox column won't change from EditType.CheckBox to EditType.NoEdit if the asset.InUse is true. When I created the column in the GridEx designer I set the EditType to CheckBox and that is where it stays.

If it makes any difference I am using Visual Studio 2013 and the GridEx control is 3.5.0.0

If you could point me in the right direction, or at some documentation / examples I would be grateful. I've tried Google, but it hasn't bought me any joy.


Solution

  • I think you cannot change the single cell Edit type , you have to change the column edit type. In your case you can set the checkbox Edit Type value to True or False (Checked or Unchecked ). Also for the Column you have to set it to ActAsSelector = True

    row.IsChecked = asset.Selected
    

    The above code will make it checked or unchecked depending on the asset.Selected value. If you want to cancel the edit operation for the unchecked cell, then there is one event called grd_CurrentCellChanging(object sender, CurrentCellChangingEventArgs e). I will just give one sample code in C# , you can convert it to VB.Net.

     private void grd_CurrentCellChanging(object sender, CurrentCellChangingEventArgs e)
        {
            if (e.Row != null)
                e.Cancel = !e.Row.IsChecked;
        }
    

    Hope it will help for you!