Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Listview DblClick in which column
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Listview DblClick in which column

 Post Reply Post Reply
Author
Message
iamgtd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 February 2009
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote iamgtd Quote  Post ReplyReply Direct Link To This Post Topic: Listview DblClick in which column
    Posted: 13 February 2019 at 7:08am
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#

---------
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.