zoukankan      html  css  js  c++  java
  • 用 BindingSource 绑定窗体中控件不失去焦点无法更新数据源的问题

          BindingSource 组件只有在输入控件失去焦点的时候才更新数据源的值,如果在某个文本框中输入内容并且焦点未移开的情况下直接点了不能获取焦点的保存按钮(菜单或图片),结果是当前文本框中输入的内容并不会被保存.解决的办法可以向窗体模拟发送一次 "Tab" 键("{TAB}"), 再发送一次 "Shift+Tab" 使焦点返回原控件.代码如下:

    if (this.ActiveControl != null && this.ActiveControl.CanFocus)
    {
        SendKeys.SendWait(
    "{TAB}");
        SendKeys.SendWait(
    "+{TAB}");
    }
  • 相关阅读:
    非常可乐
    Find The Multiple
    盲点集锦
    Fliptile
    Catch That Cow
    Dungeon Master
    hdoj 1045 Fire Net
    hdoj 1342 Lotto【dfs】
    zoj 2100 Seeding
    poj 3620 Avoid The Lakes【简单dfs】
  • 原文地址:https://www.cnblogs.com/focus/p/1280966.html
Copyright © 2011-2022 走看看