cancel
Showing results for 
Search instead for 
Did you mean: 

Choose From List is not being shown

Former Member
0 Kudos

I have one Matrix with some cols and one of them is attached to a linked button and a ChooseFromList (OITM table). Problem is after I select an item, it's code is not being shown in the matrix. Am I doing something wrong?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member233854
Active Contributor
0 Kudos

I believe the problem is the argument you are using "SAPbouiCOM.SBOItemEventArg pVal"

Try to use SAPbouiCOM.ItemEvent.

Former Member
0 Kudos

I can't use ItemEvent. This function only accepts SBOItemEventArg.

this.Matrix0.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.Matrix0_CFLA);
Former Member
0 Kudos

Seems like I was not treating the ChooseFromListAfter event. I found a blog which was helpful:

http://projectservercode.com/add-cfl-into-the-matrix-columns/

Now I'm having the following error

Cannot cast 'SAPbouiCOM.SBOItemEventArgClass' to 'SAPbouiCOM.ChooseFromListEvent'.

My code is as follow:

        private void Matrix0_CFLA(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            try
	        {
                //It Contains information about the current choose from list event,
		        SAPbouiCOM.ChooseFromListEvent oCflEvent = null;
		 
		        //Here pVal is an ItemEvent ,Thus we need to cast it as ChooseFromListEvent to access it as ChooseFromListEvent .
		        oCflEvent = (SAPbouiCOM.ChooseFromListEvent)pVal; // HERE'S THE PROBLEM
		        if (oCflEvent.SelectedObjects != null)
                    ((SAPbouiCOM.EditText)Matrix0.GetCellSpecific(pVal.ColUID, pVal.Row)).Value = oCflEvent.SelectedObjects.GetValue("ItemCode", 0).ToString();
	        }
	        catch(Exception ex)
	        {
                throw ex;
	        }
        }

former_member185682
Active Contributor
0 Kudos

Hi Rudá,

Use this:

IChooseFromListEvent oCFLEvento = (IChooseFromListEvent)(pVal);

Instead:

SAPbouiCOM.ChooseFromListEvent oCflEvent = null;
//Here pVal is an ItemEvent ,Thus we need to cast it as ChooseFromListEvent to access it as ChooseFromListEvent .
oCflEvent = (SAPbouiCOM.ChooseFromListEvent)pVal; // HERE'S THE PROBLEM

Hope it helps.

Kind Regards,

Diego Lother

Former Member
0 Kudos

Same error. SDK Help Center says:

To access this object, cast the ItemEvent object into this object.

Problem is that I can't use ItemEvent as an argument, it must be SBOItemEventArg

this.Matrix0.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.Matrix0_CFLA);
former_member185682
Active Contributor

Hi Rudá,

Sorry, I didn't see the signature of your method I thought that you used the ItemEvent.

In this case, try this:

ISBOChooseFromListEventArg oCFLEvent = (ISBOChooseFromListEventArg)(pVal);

Hope it helps.

Kind Regards,

Diego Lother

Former Member
0 Kudos

Hi Diego,

Thanks for helping me. It's working now. There's a COMException being caught, should I worry about it?

former_member185682
Active Contributor
0 Kudos

Hi Rudá,

It's not common to caught this kind of exception. In what piece of code you received this exception?

Kind Regards,

Diego Lother

former_member233854
Active Contributor
0 Kudos

Sooorry, I thought you couldn`t open the CFL.

Yes, you need to treat the ChooseFromListAfter event.

There is a sample on SDK that should help you.

C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\CSharp\17.ChooseFromList

Former Member
0 Kudos

No worries. Those samples are very confusing and outdated. I found a simpler way to treat that but I'm still getting some errors. Check my last answer please.

former_member233854
Active Contributor
0 Kudos

Does your column is binded to a datasource? If it is not, you should bind in order to show your CFL

Former Member
0 Kudos

Yes, it is. dt_SHORT_TEXT length: 15

former_member233854
Active Contributor
0 Kudos

Have a look on your form on SAP when you hover over your column if it shows on the status bar the binded properties.

Former Member
0 Kudos

Yes, it's showing UD_2 which is my UserDatasource. Do I need to treat events like ChooseFromListAfter?