删除 Infragistics webDataGrid BoundCheckBoxField 的部分检查行为

发布于 2024-12-23 06:47:48 字数 954 浏览 5 评论 0原文

我使用 Infragistics WebDataGrid ,我有 BoundCheckBoxField 列,我想删除部分检查行为。仅选中和取消选中

我在下面的课程中写的,

public class BooleanConverter : IBooleanConverter 
{
    public BooleanConverter()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public object DefaultFalseValue
    {
        get { return false; }
    }

    public object DefaultTrueValue
    {
        get { return true; }
    }

    public bool IsFalse(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }

    public bool IsTrue(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }
}

` 我这样称呼它:

     ((BoundCheckBoxField)this.uwGrid.Columns["Approval"]).ValueConverter = new BooleanConverter();

但这不是工作。

I used Infragistics WebDataGrid , I have BoundCheckBoxField column, I want remove partial check behavior. only check and uncheck

I wrote following class ,

public class BooleanConverter : IBooleanConverter 
{
    public BooleanConverter()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public object DefaultFalseValue
    {
        get { return false; }
    }

    public object DefaultTrueValue
    {
        get { return true; }
    }

    public bool IsFalse(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }

    public bool IsTrue(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }
}

`
and I call it like this:

     ((BoundCheckBoxField)this.uwGrid.Columns["Approval"]).ValueConverter = new BooleanConverter();

`

But it is not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薆情海 2024-12-30 06:47:48

绑定复选框显示绑定到它的任何数据。默认情况下,对于布尔值或可为空布尔值字段,它显示 true 表示已选中, false 表示未选中, null 表示部分。如果您有空数据,这是它应该显示的唯一时间。

如果您不喜欢这种行为,可以为该列分配不同的 ValueConverter。这将是一个实现 IBooleanConverter 的类。您可以使 null 成为选中或未选中状态。

The bound checkbox displays whatever data is bound to it. By default, for a boolean or nullable boolean field, it displays true as checked, false as unchecked, and null as partial. That's the only time it should show up- if you have null data.

If you do not like that behavior, you can assign the column a different ValueConverter. This would be a class that implements IBooleanConverter. You would make it so that null becomes checked or unchecked.

薆情海 2024-12-30 06:47:48

我确信您现在已经弄清楚了,但是您的值转换器类存在一个错误(假设您希望 null 显示为 false)。 IsFalse 方法应该是这样的:

public bool IsFalse(object value)
{
    if (value == null)
        return true;
    else
        return !Boolean.Parse(value.ToString());
}

I'm sure you figured it out by now, but there is a bug with your value converter class (assuming you want null to show as false). The IsFalse method should be like this:

public bool IsFalse(object value)
{
    if (value == null)
        return true;
    else
        return !Boolean.Parse(value.ToString());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文