Skip to Content

How to set a value in a cell

Hi,

I am working with a simple grid and use VB.NET.

I have 2 UDF in my grid: U_HOV and U_HandOver

I have made the column U_HandOver a column of checkboxes, and U_HOV a column of EditText

What I want to do?

When I click any checkbox, I want say "1" to appear on the same row in column U_HOV.

Runtime

When I click on any checkbox, "1" does not appear in the U_HOV column.

Here is my code, which I put in the following section:

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

------

If FormUID = "frmGrid" And pVal.BeforeAction = False _

And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK _

And pVal.ItemUID = "MyGrid" _

And pVal.ColUID = "U_HandOver" Then

Dim oGridRow As Integer = pVal.Row

If oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y" Then

oGrid.DataTable.SetValue("U_HOV", oGridRow, 1)

------

Could anyone help me find where is my error?

Thanks

Leon Lai

Capture.JPG (63.2 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Dec 09, 2014 at 12:36 PM

    Hi Leon,

    you also have to set the value to the datatable :

    If oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y" Then
                    oGrid.DataTable.SetValue("U_HOV", oGrid.GetDataTableRowIndex(pVal.Row), 1)
    

    -> you need the datatable row from the clicked grid row : oGrid.GetDataTableRowIndex()

    There is also an other way to set the value :

     ((SAPbouiCOM.EditTextColumn)oGrid.Columns.Item("U_HOV")).SetText(pVal.Row, "1")
    

    Which would set the Text in the Cell of the Grid.

    regards,

    Maik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 09, 2014 at 12:36 PM

    Hi,

    Try to write same code on lost focus event of ColUID.

    If FormUID = "frmGrid" And pVal.BeforeAction = False _

    And pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOSTFOUCS _

    And pVal.ItemUID = "MyGrid" _

    And pVal.ColUID = "U_HandOver" Then

    Dim oGridRow As Integer = pVal.Row

    If oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y" Then

    oGrid.DataTable.SetValue("U_HOV", oGridRow, 1)

    endif

    regards,

    Prasad

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 09, 2014 at 12:41 PM

    Hi Leon,

    I think you have to set the value in the data table row also:

    Dim oGridRow As Integer = pVal.Row

    Dim dataTableRow As Integer = oGrid.GetDataTableRowIndex(pVal.Row)

    If oGrid.DataTable.GetValue("U_HandOver", dataTableRow).ToString() = "Y" Then

    oGrid.DataTable.SetValue("U_HOV", dataTableRow, 1)

    ,

    ps: haven't tested the code above, you might need to do some adjustment.


    Best regards,

    Pedro Magueija


    View Pedro Magueija's profile on LinkedIn

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.