I've got a xamdatagrid bound to a custom object. One of the fiels is a bool and as the default...the grid is using the xamcheckeditor as the control. That is all working fine. However, I need to know when the box is checked and unchecked so I can set AllowEdit on some fields depending on true or false. Here is my xaml....I wanted to use the EditModeEnding...and according to the checkeditor I should be able to specifiy that...however...I don't see that as an allowable parameter to set...any advice?
<
>
/>
Hello,
AllowEdit you can be set of the Field's Settings and it will apply for all of the cells in that field. However, if you want to do it on a record level basis, you can also use the EditModeStarting event and cancel it if the CheckBox in that column is checked, like this:
void xamDataGrid1_EditModeStarting(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartingEventArgs e)
{
DataRecord record = e.Cell.Record as DataRecord;
if (record != null && (bool)record.Cells["UDFNameDataGridColIsDiscreet"].Value == false)
e.Cancel = true;
}
Alex,
Thanks...but do I also need to change the XAML...notice I don't explicitly define the field as using the xamCheckEditor (it is the default editor used because the field is a bool...but that's at run time). As such, in the xaml I can't say "....EditModeStarting="methodname"...it doesn't recognize EditModeStarting.
I was referring to the XamDataGrid's EditModeStarting event. Unless you have retemplated the CellValuePresenter, this event should fire for all the cells when they go into edit mode. Do you have a sample that we can look into?
Ok...I'm using the EditModeStarting for the grid..so here's what I have now...If I find that the checkbox is true (checked)...I want to set the AllowEdit property of three other cells in that row to false....However...when doing
record.Cells["UDFNameDataGridColMinValue"].AllowEdit = false
There appears to be no AllowEdit property.
if (record != null) { if ((bool)record.Cells["UDFNameDataGridColIsDiscreet"].Value == true) { record.Cells[ "UDFNameDataGridColMinValue"].? = false; //no allow edit property record.Cells[ "UDFNameDataGridColMaxValue"].? = false; //no allow edit property record.Cells[ "UDFNameDataGridColMaxLength"].? = false; //no allow edit property } } //e.Cancel = true;
if
(record != null) {
if ((bool)record.Cells["UDFNameDataGridColIsDiscreet"].Value == true) { record.Cells[
record.Cells[
"UDFNameDataGridColMinValue"].? = false; //no allow edit property record.Cells[
"UDFNameDataGridColMaxValue"].? = false; //no allow edit property record.Cells[
"UDFNameDataGridColMaxLength"].? = false; //no allow edit property } }
//e.Cancel = true;
Never mind my last post.... i needed to specify ".Field.Settings.AllowEdit = false"...thanks for your excellent support on this forum.