Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4695
disable the cell in ultragrid when value=checked
posted

Dear all,

I have the ultragrid that show the checkbox in the cell.

How can I disable the cell when the checkbox is checked??

What is the event?? What is the steps to do this as below??

(1) Create the event and assign the event to the ultragrid??(STEPS)

(2) e.g. On Databound, when cell.value==true, disable it. (ANY SAMPLE CODE??)

  • 5520
    Suggested Answer
    posted

     private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)

            {

                if ((bool)e.Row.Cells[0].Value)

                {

                    e.Row.Cells[0].Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;

                }

            }

     

            private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)

            {

                if ((bool)e.Cell.Value && e.Cell.Column.Key == "")

                    e.Cell.Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;

            }

    • 4695
      Suggested Answer
      posted in reply to Hady JAWHAR

      I am using below code. But find that when I checked, it becomes disabled also.

      I want only on one time display (disabled the field if they are true in the datasource) when opening the form. On other non-Checked checkbox, when I checked it, it still enabled. As this status is important for me to process when I click OK button on the form. as I will ignore the disabled checkbox field.

      Could you tell me how to do??

      ----------------------------------------------------------------------------------

      private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)

              {

                  if ((bool)e.Row.Cells[0].Value)

                  {

                      e.Row.Cells[0].Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;

                  }

              }

      • 469350
        Verified Answer
        Offline posted in reply to Raymond Chiu

        The InitializeRow event doesn't just fire the first time the row is created, it also fires any time any value in the row is changed. This makes it ideal for changing the format or appearance of a cell or row based on the value in a cell.

        In your case, if you only want to disable the cell in the initial creation of the row, then you should check that e.ReInitialize is false. This will indicate that it's the creation of the row that is causing it to be initialized.

        • 5520
          Suggested Answer
          posted in reply to Raymond Chiu

          after setting the datasource, you can loop the rows :

           

          foreach (ultragridrow ugr in ultragrid1.rows)

          if((bool)ugr.cells[0].Value)

          {

          ugr.Cells[0].Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;

          }