Skip to Content
0
Former Member
Apr 09, 2007 at 03:56 PM

delete last matrix row

37 Views

I have read and tried all the threads I could find on this subject and I still am not able to delete the last row in my UDO matrix. I am including a section of my code (in C#) including all the various attempts that have been commented out as I tried them. Can someone help me out? My SAP B1 version is 2005 A (6.80.318) SP:01 PL:14.

                    if ((pVal.ItemUID == "del") & (pVal.EventType == BoEventTypes.et_ITEM_PRESSED))
                    {
                        Form oForm = B1Connections.theAppl.Forms.Item(FormUID);
                        if (oForm.PaneLevel == 1)
                        {
                            Item oItem = oForm.Items.Item("mtx_0");
                            Matrix oMatrix = ((Matrix)(oItem.Specific));
                            Columns oColumns = oMatrix.Columns;
                            for (int i = 1; i <= oMatrix.VisualRowCount; i++)
                            {
                                if (oMatrix.IsRowSelected(i) == true)
                                {
                                    // oMatrix.ClearSelections();
                                    
                                    //Column oCol = oColumns.Item("col_f");
                                    //oEdit = ((EditText)(oCol.Cells.Item(i).Specific));
                                    //int oRowNo = int.Parse(oEdit.Value.ToString());
                                    //oEdit.Value = "";

                                    oMatrix.DeleteRow(i);
                                    oMatrix.FlushToDataSource();
                                                                                if (oMatrix.RowCount == 1)
                                    {
                                        oMatrix.Clear();
                                        oMatrix.FlushToDataSource();

                                    //    DBDataSource oDBDS = ((DBDataSource)(oForm.DataSources.DBDataSources.Item("@CIP_OHSL")));
                                    //    try
                                    //    {
                                    //        int ii = 0;
                                    //        oDBDS.RemoveRecord(ii);
                                    //    }
                                    //    catch (System.Exception er)
                                    //    {
                                    //        B1Connections.theAppl.MessageBox(er.ToString(), 0, "OK", "", "");
                                    //    }
                                    }

                                    oMatrix.LoadFromDataSource();

                                    // oMatrix.DeleteRow(i);
                                    // oMatrix.FlushToDataSource();
                                    
                                    // oMatrix.FlushToDataSource();
                                    // oMatrix.LoadFromDataSource();
                                    // oMatrix.DeleteRow(i);
                                    // oMatrix.LoadFromDataSource();

                                    if (oForm.Mode != BoFormMode.fm_ADD_MODE)
                                    {
                                        oForm.Mode = BoFormMode.fm_UPDATE_MODE;
                                    }
                                    break;
                                }
                            }
                        }
                        //oForm.Update();
                        BubbleEvent = false;
                    }

Thanx!