This is a migrated thread and some comments may be shown as answers.

[Solved] Set Cell to Disabled when Pasting from Excel (based on another field value)

1 Answer 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matthew
Top achievements
Rank 1
Matthew asked on 28 Oct 2011, 09:55 PM
I have radGrid that a user pastes information into from Excel.

If the value in a CheckBoxColumn = FALSE I need to disable another field in that same Row.  It needs to do this individually for each Row.

I can do this no problem in the CellValidating Event (if they change the field value after the data has already been pasted in).  However, I need to be able to do this as well from the PastingCellClipboardContent Event.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 28 Oct 2011, 11:34 PM
I resolved this by binding to the Field I wanted to Disable to the CheckBox field and implementing a Converter.

InvertBooleanConverter.cs
public class InvertBooleanConverter : IValueConverter
{
    public Object Convert(Object value, Type targetType, Object parameter, System.Globalization.CultureInfo culture)
    {
        return (bool)value ? false : true;
    }
 
    public Object ConvertBack(Object value, Type targetType, Object parameter, System.Globalization.CultureInfo culture)
    {
        return (bool)value ? true : false;
    }
}

MainPage.xaml
xmlns:converter="clr-namespace:my.name.space"

<UserControl.Resources>
            <converter:InvertBooleanConverter x:Key="InvertBooleanConverter" />
</UserControl.Resources>


<telerik:GridViewDataColumn Header="Rate" DataMemberBinding="{Binding Rate, Mode=TwoWay, ValidatesOnExceptions=True, StringFormat=\{0:c\}}" IsReadOnlyBinding="{Binding Adjustment, Converter={StaticResource InvertBooleanConverter}}" />
Tags
GridView
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Share this question
or