I'm using the Codejock-Listview-Control with the report view (xtpListViewReport). In the listview there are ListviewItems with some ListviewSubItems. I use the doubleclick-event to know which item and in which column was doubleclicked.
The DblClick-event is also fired if it is clicked in the area without items. So I can't use the SelectedItem-property to check which item is doubleclicked.
This behaviour I solved with the Hittest-method. This works also if it's vertically scrolled.
To check in which column was clicked, I calc the column-width - see the code. But if there is horizontally scrolled, the result is wrong.
Question: How Can I detect the horizontally scroll-offset?
private void cjListView_DblClick(object sender, EventArgs e) { int f = 16; // it's necessary for a correct result XtremeSuiteControls.ListViewItem lvi = cjListView.HitTest((float)currentmouse_x * f, (float)(currentmouse_y - cjListView.Margin.Top) * f);
if (lvi == null) { // DblClick was not on a ListViewItem return; }
// get the clicked column int x_coordinate= cjListView.Margin.Left; int selected_col = 0; for (int i = 1; i < cjListView.ColumnHeaders.Count + 1; i++) { x_coordinate += cjListView.ColumnHeaders.Width; if (x_coordinate > currentmouse_x) { selected_col = i; break; } } MessageBox.Show("Hittest: " + lvi.Text + Environment.NewLine + "Column: " + selected_col.ToString());
}
private void cjListView_MouseUpEvent(object sender, AxXtremeSuiteControls._DListViewEvents_MouseUpEvent e) { currentmouse_x = e.x; currentmouse_y = e.y; }
------------- ---------
OS: Win 10 64 bit
Codejock Version 22.1 ActiveX
MS Visual Studio 2022 - C#
---------
|