cancel
Showing results for 
Search instead for 
Did you mean: 

Line Selected

Former Member
0 Kudos

Please advice on how to perform the following operation.

When I click on one of the grid fields, the whole line should be selected, but it shouldnu2019t allow the user to edit that field.

Regards,

Jose

Accepted Solutions (0)

Answers (1)

Answers (1)

Nussi
Active Contributor
0 Kudos

hi Jose,

be sure you set the correct oGrid.SelectionMode and

use this c# code snippet.

the first column in grid is called RowsHeader.

the trick is to catch when you click on a cell.

use this with the click event and it works:


    if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK && pVal.InnerEvent == false && pVal.BeforeAction == false && pVal.ColUID != "RowsHeader")
    {
        if (pVal.ItemUID == "grid")
        {
            oForm = globals.SBO_Application.Forms.Item(FormUID);
            ((SAPbouiCOM.Grid)(oForm.Items.Item("grid").Specific)).Columns.Item("RowsHeader").Click(pVal.Row, false, 0);
 
        }
 
    }

it should help you - it's working for me.

to prevent changing disable the columns -> set Editable to false

or disable the grid

regards

David

Former Member
0 Kudos

Thanks David.

Can You explain this:

how to use the SelectedRows and IsSelected?

Regards,

Nussi
Active Contributor
0 Kudos

Hi,

here you ask if the variable rownum is selected. true means a row is selected (orange selection bar)

If oMatrix.IsRowSelected(rownum) = true

here you select a single row with the orange bar:

oMatrix.SelectRow(rownum, true, false)

Description: RowNum As Long, Select As Boolean, MultiSelect As Boolean

Select

A boolean value specifying whether or not the row is selected.

True - selected.

False - unselected (cleared).

MultiSelect

A boolean value specifying the status of the last selected when multiple rows are selected.

True - last row remains selected.

False - last row will not remain selected.

regards

David

Former Member
0 Kudos

does this work for the Grid?

Regards,

Jose

Nussi
Active Contributor
0 Kudos

oh Jose,

it was so late yesterday that i posted the Matrix Methods.

for Grid it is:

Grid.Rows.IsSelected(rowIndex)

Grid.Rows.SelectedRows.Add(rowIndex)

Grid.Rows.SelectedRows.Remove(rowIndex)

lg David

Former Member
0 Kudos

Thanks David.

I am Using this Code:

Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

If pVal.ItemUID = "Grid" Then

For I = 0 To TotalLine

rowIndex = oGrid.Rows.IsSelected(I)

Next

End If

I am using variable rowIndex to detect what row is selected in the grid, but it always is false.

Regards,

Jose

Nussi
Active Contributor
0 Kudos

well,

1. maybe try to start the loop with 1.

For I = 1 To TotalLine

2. the return value is true or false

Dim RowSelected as Boolean

RowSelected = oGrid.Rows.IsSelected(I)

if RowSelected = true then

lg David

Former Member
0 Kudos

I have grid that when you click on it with the mouse Left button, doesnu2019t matter where you click on the line is highlighted orange.

The grid has collapsed on the first level.

This is the code in using:

Case SAPbouiCOM.BoEventTypes.et_CLICK

If pVal.ItemUID = "grid" Then

For I = 1 To TLine

RowSelected = oGrid.Rows.IsSelected(I)

If RowSelected = True Then

SBO_Application.MessageBox("HOLA" & I)

End If

Next

End If

The first line is loaded with the variable RowSelected=true, but is show as I have clicked on the third line.

Nussi
Active Contributor
0 Kudos

oh man - that many questions

i think the best is to extend the grid before you collect the selected rows.

i never tried it but i think that getting collapsed rows can be problematic.

the fatherrows to collapse/extend can count or not count.

well - i did my best

regards

David

Former Member
0 Kudos

Thanks David for your help.