2010-05-10 115 views
1

我正在嘗試從矩陣讀取。 我有到現在爲止的代碼是:SAP B1:從矩陣讀取

SAPbouiCOM.Matrix matrix = (SAPbouiCOM.Matrix SBO_Application.Forms.ActiveForm.Items.Item("38").Specific;    
SAPbouiCOM.Column col = matrix.Columns.Item("1") ; 
SAPbouiCOM.Cells cells = col.Cells; 
String cell = cells.Item(2).Specific.ToString(); 
String f = cell.ToString(); 

絃樂的無(電池和f)給我的單元格的值...

任何想法?

回答

2

@Miguel試試這個代碼

string ColId = "1"; //Set The Column Name to read 
    Int32 Row  = 2; //Set the Row to Read 
    Matrix oMatrix =(Matrix)SBO_Application.Forms.ActiveForm.Items.Item("38").Specific; //Get Access to the Matrix 
    EditText oEdit =(EditText)oMatrix.Columns.Item(ColId).Cells.Item(Row).Specific; //Cast the Cell of the matrix to the respective type , in this case EditText 
    string sValue = oEdit.Value; //Get the value form the EditText 

米格爾還檢查SAP Business One SDK Forum有關SAP B1任何問題。

0
SAPbouiCOM.EditText EditValue; 
string strValue; 
String ColUId = "col_1" // Column UID 
Int32 Row  = 1  //Row Number 
Item item  = form.Items.Item("38"); 
Matrix matrix = ((Matrix)(item.Specific)); 
EditValue  = (SAPbouiCOM.EditText)matrix.GetCellSpecific(ColUId, Row); 
strValue  = EditValue.Value.ToString().Trim(); 
0

我們也可以按照以下方式編寫。我在vb.net中做了這個

Dim matrix as SAPbouiCOM.Matrix 

matrix = oForm.Items.Item("38").Specific 


dim f as string = matrix .Columns.Item("3").Cells.Item(2).Specific.value.tostring 

這裏的單元格號是2,列號是3。所以f值將是3列值的第2行。

0

如果您嘗試從窗體讀取某些列值,那麼使用SQL查詢會更容易。這就是我所做的。

string firmenname = ""; 
string ort = ""; 
string plz = ""; 
string strasse = ""; 
SAPbobsCOM.Recordset mRs1 = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); 
string sqlstring = " select top 1 street, zipcode, city, country, address from CRD1 where cardcode = '" + codeid + "' and adrestype ='B' "; 
mRs1.DoQuery(sqlstring); 
while (!mRs1.EoF) 
{ 
strasse = mRs1.Fields.Item("street").Value.ToString(); 
ort = mRs1.Fields.Item("city").Value.ToString(); 
plz = mRs1.Fields.Item("zipcode").Value.ToString(); 
firmenname = mRs1.Fields.Item("address").Value.ToString(); 
mRs1.MoveNext(); 
} 

我有點像你一樣的問題。但是在我提出這個想法之後,很容易從具有列數的任何形式讀取值。你所要做的就是「查看 - >系統信息」,並知道在哪個數據庫表中存儲值。然後編寫你想要的SQL查詢。

希望這可以幫助你!

0

如果您需要從矩陣得到的數據:

VAR cellValue = oMatrix.Columns.Item(欄的ID或指數).Cells.Item(行的索引).Specific.Value;

但是如果你需要更新矩陣值要投山坳到的EditText OBJ喜歡:

var oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item(Column's Id or Index).Cells.Item(Row's Index).Specific; 
oEdit.Value = "1";