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?
Does your column is binded to a datasource? If it is not, you should bind in order to show your CFL
Yes, it is. dt_SHORT_TEXT length: 15
Have a look on your form on SAP when you hover over your column if it shows on the status bar the binded properties.
Yes, it's showing UD_2 which is my UserDatasource. Do I need to treat events like ChooseFromListAfter?
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
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.
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; } }
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
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);
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
Hi Diego,
Thanks for helping me. It's working now. There's a COMException being caught, should I worry about it?
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
I believe the problem is the argument you are using "SAPbouiCOM.SBOItemEventArg pVal"
Try to use SAPbouiCOM.ItemEvent.
I can't use ItemEvent. This function only accepts SBOItemEventArg.
this.Matrix0.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.Matrix0_CFLA);