Skip to Content
0

Disable specific field on custom form UI API

Apr 13, 2017 at 08:38 AM

85

avatar image

Hello everybody,

I have created a custom form using SAP Business One Studio for Visual Studio and have attached a Matrix on this form. I have added three ComboBoxes as fields and populate them with specific values stored in a table. When the form is loaded Form's ComboBoxes are populated based on the values stored in SQL tables.

My issue now is that I would like to disable the third ComboBox after it's value is selected in order to prevent users from changing it's value.

Here is the code I use to populate my Form once initialized

foreach (var s in GetSettings())
                {
                    oComboBox = (SAPbouiCOM.ComboBox)this.Matrix1.Columns.Item("oTy").Cells.Item(j).Specific;
                    oComboBox.Select(s.Item1);
                    oComboBox = (SAPbouiCOM.ComboBox)this.Matrix1.Columns.Item("oUs").Cells.Item(j).Specific;
                    oComboBox.Select(s.Item2);
                    oComboBox = (SAPbouiCOM.ComboBox)this.Matrix1.Columns.Item("oAc").Cells.Item(j).Specific;
                    oComboBox.Select(s.Item3);
oComboBox.Item.Enabled = false;
                    this.Matrix1.AddRow();
                    j++;
                }

Have also tried to disable previous line ComboBox but again got the same exception saying that field got focus and can not be disabled.

Any help solving this issue will be much appreciated.

Kind regards,

Dimitris Theotokatos

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Dimitris Theotokatos Apr 13, 2017 at 12:45 PM
0

Hello Diego,

I tried your suggestion but still got the same exception.
I finally managed to solve my problem by using Item Event and when a user tries to click the combo box to change it's value, then another click is performed on form from UI API disabling user to change the original value.

It is not the best solution, I suppose, but what I found out is that UI API can not disable specific rows/fields but only columns, so this is the best solution I figured out so far.

Thanks for your help and your time.

Kind regards,

Dimitris Theotokatos

Share
10 |10000 characters needed characters left characters exceeded
DIEGO LOTHER Apr 13, 2017 at 12:06 PM
1

Hi Dimitris,

You need move the focus to another field before disable the field.

In your case you can do this with a click in the next or previous column:

this.Matrix1.Columns.Item("oUs").Cells.Item(j).Click();

Hope it helps.

Kind Regards,

Diego Lother

Share
10 |10000 characters needed characters left characters exceeded