Highlighted
Absent Member.
Absent Member.
805 views

Datagridview - Failed to get the value of a cell after to click on the titles to sort.

Jump to solution

Datagridview - Failed to get the value of a cell after to click on the titles to sort.

Error of index.

How can I solve this problem?

 

code:

method-id dataGridView1_CellContentClick final private.
01 ws-protocolo     pic x(11).

procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellEventArgs.

set ws-protocolo to dataGridView1::Rows::Item(e::RowIndex)::Cells["Protocolo"]::Value::ToString()

end-code


0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Datagridview - Failed to get the value of a cell after to click on the titles to sort.

Jump to solution

If the click occurs in the Column Header the RowIndex will be -1.

Try checking this before executing your statement:

          if e::RowIndex > -1

             set ws-protocolo to dataGridView1::Rows::Item(e::RowIndex)::Cells["Protocolo"]::Value::ToString()

          end-if

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Datagridview - Failed to get the value of a cell after to click on the titles to sort.

Jump to solution

If the click occurs in the Column Header the RowIndex will be -1.

Try checking this before executing your statement:

          if e::RowIndex > -1

             set ws-protocolo to dataGridView1::Rows::Item(e::RowIndex)::Cells["Protocolo"]::Value::ToString()

          end-if

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.