Guys,
I have a situation (GDBG and ComboBox Cell Type)where specific cell values cannot be empty (deleted), so I try to work around CurrentCellDeleting event setting e.Cancel = true but the cell value is still deleted.
Should I use a different event, or a combination of events to avoid the deletion of a cell value?
TIA
Jose
TH
Thomas
October 1, 2003 01:40 PM UTC
Hi Jose
You can set the DropDownStyle to Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive, so you can only choose the values from the list and the value cannot be deleted.
Regards
Thomas
AD
Administrator
Syncfusion Team
October 1, 2003 01:50 PM UTC
> Hi Jose
>
> You can set the DropDownStyle to Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive, so you can only choose the values from the list and the value cannot be deleted.
>
> Regards
> Thomas
If I set the DropDownStyle to Exclusive, the type ahead functionality will not work which is an important requirement in our application.
AD
Administrator
Syncfusion Team
October 1, 2003 02:43 PM UTC
> Guys,
>
> I have a situation (GDBG and ComboBox Cell Type)where specific cell values cannot be empty (deleted), so I try to work around CurrentCellDeleting event setting e.Cancel = true but the cell value is still deleted.
>
> Should I use a different event, or a combination of events to avoid the deletion of a cell value?
>
> TIA
> Jose
Try also the ClearingCells event and set e.Cancel = true
Stefan
AD
Administrator
Syncfusion Team
October 1, 2003 05:35 PM UTC
> > Guys,
> >
> > I have a situation (GDBG and ComboBox Cell Type)where specific cell values cannot be empty (deleted), so I try to work around CurrentCellDeleting event setting e.Cancel = true but the cell value is still deleted.
> >
> > Should I use a different event, or a combination of events to avoid the deletion of a cell value?
> >
> > TIA
> > Jose
> Try also the ClearingCells event and set e.Cancel = true
>
> Stefan
If I cancel the ClearingCells event then none of the cells can be deleted.
AD
Administrator
Syncfusion Team
October 1, 2003 06:27 PM UTC
> If I cancel the ClearingCells event then none of the cells can be deleted.
You could check for grid.Model.Selections.GetSelectedRows(true, false).Count > 0
and only then set e.Cancel = true
Stefan
AD
Administrator
Syncfusion Team
October 2, 2003 10:47 AM UTC
I didn't work for me. Attached is a simple example where the first column of the grid should not be deleted.
I'm using both CurrentCellDeleting and ClearingCells events.
Thanks
AD
Administrator
Syncfusion Team
October 3, 2003 03:31 PM UTC
Set
style.DropDownStyle = GridDropDownStyle.AutoComplete;
and use these event handlers:
private void gridDataBoundGrid1_ClearingCells(object sender, Syncfusion.Windows.Forms.Grid.GridClearingCellsEventArgs e)
{
if (e.RangeList.AnyRangeIntersects(GridRangeInfo.Col(1)))
e.Handled = true;
}
private void gridDataBoundGrid1_CurrentCellDeleting(object sender, CancelEventArgs e) {
if (gridDataBoundGrid1.CurrentCell.ColIndex == 1)
e.Cancel = true;
}
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
if (gridDataBoundGrid1.CurrentCell.ColIndex == 1)
{
if (e.Text == "")
e.Cancel = true;
}
}
I think it should be fine but if you run into problems with AutoComplete mode for the combobox send us a direct trac incident and we can send you dl instructions for a patch.
Stefan
AD
Administrator
Syncfusion Team
October 6, 2003 03:43 PM UTC
Still have 2 issues,
1) If I select column 1 and 3 and press delete, column3 cell values are not cleared (obviously because the way we are handling the event).
Is there any other way where "read-only" cells are not cleared and "read-write" cells are cleared (which is the default behavior of the grid) when both cell types are part of the same selection?
2) While editing column1 if I clear cell value, the application starts what seems to me an infinitive loop.
Thanks
AD
Administrator
Syncfusion Team
October 6, 2003 05:23 PM UTC
Jose,
if you don't want to cancel the deletion operation in such scenarion than ClearingCells is not so good.
Let me suggest to remove the ClearingCells event handler and instead use the following event handler:
private void Model_DataProviderSaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
if (e.ColIndex == 1 && e.Style.HasText && e.Style.Text == "")
e.Handled = true;
}
(If you would use a regular grid then you should handle SaveCellInfo instead.)
Regarding the freeze. I think you are hitting here a bug that we fixed just recently. If you open a direct-trac incident we can give you acces to the latest version/patch.
Stefan