zoukankan      html  css  js  c++  java
  • gridControl-The BindingSource.AddingNew event does not fire until I begin typing into the new row

    The BindingSource.AddingNew event does not fire until I begin typing into the new row

    Tags:

    Dan Tallent10 years ago

      • I have setup the form as follows:
        The GridView.OptionsView.NewItemRowPosition = Bottom
        The view has most of the columns from MyDataSource
        The GridControl's datasource is set to MyBindingSource
        When I click on any column of the new "empty" row at the bottom of the grid, I am allowed to edit. Unfortunately until I begin to type the BindingSource.AddingNew event is not fired.
        This is preventing me from setting some of the values on the new row until the user types.
        I tested this scenario with a standard System.Windows.Forms.DataGridView bound to the same bindingsource. As soon as I click on the new row of the DataGridView, the AddingNew event is triggered immediately. This is perfect because it allows me to setup default values and they are reflected to the user as soon as I click on the new row.
        What do I need to change in my Gridview / GridControl to get this same effect.
        Thanks

    •  
    • Svetlana (DevExpress Support)10 years ago

      Hi Charles,
      Thank you for the message.
      To initialize new rows, handle the GridView.InitNewRow event. However, this event is raised after an end-user starts typing in a new item row.
      So, to force the GridView.InitNewRow/BindingSource.AddingNew event to fire when an end-user clicks within the new item row, handle the GridView.ShownEditor event and set the GridView.ActiveEditor.IsModified property to true:

      
       

      [C#]

      private void gridView1_ShownEditor(object sender, EventArgs e) { 
           GridView view = sender as GridView; 
          if(view.IsNewItemRow(view.FocusedRowHandle)) 
              view.ActiveEditor.IsModified = true; 
      }

    Please try this approach, and let me know your results.
    Thanks,
    Svetlana

    • Dan Tallent10 years ago

      Exactly what I was looking for. It worked perfectly. Your guys support rocks!
      Thanks

    • Svetlana (DevExpress Support)10 years ago

      Hi Charles,
      Please don't hesitate to contact us in case of any difficulty. We will be happy to help you resolve any problem!
      Thanks,
      Svetlana

  • 相关阅读:
    pymysql
    flask WTForms
    线程安全问题
    flask学习2
    @functools.wraps(func)
    Solidity开发神器Remix
    Web3j实现智能合约
    基于Ubuntu Docker环境下进行以太坊实践
    以太坊RLP机制分析
    以太坊网络服务分析
  • 原文地址:https://www.cnblogs.com/grj001/p/12222976.html
Copyright © 2011-2022 走看看