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
505
Change Text of ButtonUIElment embed inside TimeSlotUIElement issue
posted
I have this code to create Button in a UltraMonthViewSingle, 
I use click event of embebded ButtonUIElement to change the Text of it,
But when I change the Form size (maximum Form) or click on other UIElement (DayNUmberUIElement, Owner),
the Text of ButtonUIElement return to its orginial value.
Help me  to solve this problem, please.
Thank you.
public void AfterCreateChildElements(UIElement parent)
        {
         
            if (parent is TimeSlotUIElement)
            {


                ButtonUIElement txtUI = new ButtonUIElement(parent);
                txtUI.Rect = parent.Rect;
             
                txtUI.Text = "OK";
                txtUI.ElementClick += OnEmbeddedButtonClicked;
                parent.ChildElements.Add(txtUI);
             }

               
        }
protected virtual void OnEmbeddedButtonClicked(object sender, UIElementEventArgs e)
        {

            if (e.Element.GetType() == typeof(Infragistics.Win.ButtonUIElement))
            {
                ButtonUIElement btn = e.Element as ButtonUIElement;

                if (btn.Text == "OK") btn.Text = "CH";
              
                
            }
          

Parents
  • 69832
    Verified Answer
    Offline posted

    When the button is clicked, you set the Text on the instance that was set, but that instance will be removed each time the control's elements are regenerated. You have to persist the value of the Text property globally, and then access that persisted value when setting it in AfterCreateChildElements.

Reply Children
No Data