首页 \ 问答 \ 在WPF Threestate Checkbox中捕获不确定状态(Capturing indeterminate state in WPF Threestate Checkbox)

在WPF Threestate Checkbox中捕获不确定状态(Capturing indeterminate state in WPF Threestate Checkbox)

所以,我在WPF应用程序中有一个简单的三态复选框:

<CheckBox Checked="CheckBox_Checked"
          Unchecked="CheckBox_Checked"
          IsThreeState="True" />

现在,我希望此复选框在其状态发生变化时执行某些操作,这就是为什么我将CheckedUnchecked事件设置为视图中的相同方法。 由于这只是一个非常简单的例子,这就是我在该方法中所做的一切:

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Test");
    }

现在的问题是,当选中或取消选中复选框时,这是有效的,当其值更改为不确定状态时,没有任何反应。 很明显,我正在为CheckedUnchecked设置事件,但缺少一些不确定状态的事件。

在设置不确定状态时,我需要使用什么事件才能采取措施?


So, I have a simple threestate checkbox in a WPF application:

<CheckBox Checked="CheckBox_Checked"
          Unchecked="CheckBox_Checked"
          IsThreeState="True" />

Now, I want this checkbox to do something whenever its state is changed, which is why I'm setting the Checked and Unchecked events to the same method in the view. Since this is just a very simple example, this is all I'm doing in that method:

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Test");
    }

Now the problem is that while this works when the checkbox is checked or unchecked, nothing happens when its value is changed to the indeterminate state. It's clear that I'm setting events for Checked and Unchecked but missing some event for the indeterminate state.

What event do I need to use in order to take action when the indeterminate state is set?


原文:https://stackoverflow.com/questions/23213775
更新时间:2022-07-10 08:07

最满意答案

如果要检索数组中的信息(或任何可以遍历字符串的结构),可以创建如下方法:

public String[] getDBNames(){
    String[] result;
    try {
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT name FROM sqlite_master "); 
        sb.append("WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' ");
        sb.append("UNION ALL ");
        sb.append("SELECT name FROM sqlite_temp_master "); 
        sb.append("WHERE type IN ('table','view') ");
        sb.append("ORDER BY 1");

        Cursor c = _db.rawQuery(sb.toString(), null);
        c.moveToFirst();

        result = new String[c.getCount()];
        int i = 0;
        while (c.moveToNext()) {
            result[i]= c.getString(c.getColumnIndex("name"));
            i++;
        }
        c.close();
    }
    catch(SQLiteException e){
        Log.e("OOPS", e);
    }
    return result;
}

If you want to retrieve the info in an array (or any structure which you can iterate through strings), you can make a method like:

public String[] getDBNames(){
    String[] result;
    try {
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT name FROM sqlite_master "); 
        sb.append("WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' ");
        sb.append("UNION ALL ");
        sb.append("SELECT name FROM sqlite_temp_master "); 
        sb.append("WHERE type IN ('table','view') ");
        sb.append("ORDER BY 1");

        Cursor c = _db.rawQuery(sb.toString(), null);
        c.moveToFirst();

        result = new String[c.getCount()];
        int i = 0;
        while (c.moveToNext()) {
            result[i]= c.getString(c.getColumnIndex("name"));
            i++;
        }
        c.close();
    }
    catch(SQLiteException e){
        Log.e("OOPS", e);
    }
    return result;
}

相关问答

更多
  • 可能这不是您创建的第一个数据库架构。 如果编辑数据库模式,则必须增加数据库版本。 否则,不会调用onUpdate()。 尝试: private static final int DATABASE_VERSION = 2; Probably this isn't your first DB-schema, that you created. You have to increase your DB-version, if you edit your DB-schema. Otherwise neither ...
  • 所有应用程序(有权访问它们)都可以访问系统联系人数据库中的所有联系人。 如果要隐藏联系人,则必须将它们存储在您自己的私有数据库中。 All contacts in the system contacts database are accessible to all apps (that got the right to access them). If you want to hide contacts, you have to store them in your own, private databas ...
  • 养成很好地格式化代码的习惯。 最后一列定义没有逗号: String CREATE_USER_TABLE = "CREATE TABLE " + TABLE_USER + "(" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_NAME + " TEXT, " + KEY_EMAIL + " TEXT, " ...
  • 如果用户可以看到数据库文件,则可以通过多种方式显示该文件是SQLite 3文件。 但是,在Android上,数据库文件存储在单独的目录中,通常不作为文件显示。 因此, 没有要求甚至建议文件扩展名。 在实践中,许多应用程序不使用扩展; 但你可以使用任何有意义的东西。 If the database file can be visible to the user, there are several possibilities to show that the file is an SQLite 3 file. ...
  • 尝试从手机卸载应用程序,然后重新启动该应用程序。 在构建Android应用程序时经常会出现此问题,在该应用程序中,您对数据库模式进行了更改但忘记重新创建数据库。 Try uninstalling the app from the phone and then re-launching the application. This issue often occurs when building an android app, where you make a change to the database sc ...
  • 首先,您必须获取DatabaseHelper.class的 实例才能使用该类。 myDb = new DatabaseHelper(LoginActivity.this); storedPassword = myDb.getData(name, password); //like this. 其次,您应该在查询中使用这样的内容。 替换为此。 Cursor mCursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE NAME='?' A ...
  • 使用sql lite。 Android为它提供了很好的支持。 sqlite数据库只是SDCard上的一个文件。 它与应用程序无关,因此删除和/或更新应用程序不会影响数据库。 (除非你写了更新代码来更新你的db :)) Sqlite易于使用,结构紧凑,显然可以轻松存储在您的SD卡上。 连接到它的能力等都是在android中完成的。 如果您打算在设备/人员之间共享应用程序中的信息,则只需要Web服务器数据库。 如果数据仅对您的本地设备是必需的,那么肯定使用sqlite。 Use sql lite. Androi ...
  • 你可以尝试以下方式。 创建名为DBAdapter.java的类并添加以下代码。 public class DBAdapter { private static final String DATABASE_NAME = "Your database name"; private static final String DATABASE_CREATE_USERS = "create table TABLE_NAME ( UserID integer primary ke ...
  • 不,每次运行此代码段时都不会创建数据库。 在您的示例中, onCreate方法运行创建表的SQL脚本。 但是在发布的代码中没有调用此方法。 那不是偶然的。 当第一次实例化DatabaseHelper时,您不会显式调用此方法,Android会执行此操作。 在发布的代码中有一个new DatabaseHelper(this); 。 与您可能假设的相反,这并不意味着会有对onCreate的调用。 创建此类的实例并调用onCreate方法是非常不同的事情。 No, the database is not creat ...
  • 如果要检索数组中的信息(或任何可以遍历字符串的结构),可以创建如下方法: public String[] getDBNames(){ String[] result; try { StringBuilder sb = new StringBuilder(); sb.append("SELECT name FROM sqlite_master "); sb.append("WHERE type IN ('table','view') AND n ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)