0
Answer

Getting the Scrollbar offset

Ask a question
Hi guys,

I am currently writing a small app that contains an editable ListView based on the one detailed here:

http://www.c-sharpcorner.com/Code/2002/July/EditableListView.asp

I noticed a small bug in the code in case your interested, to correctly work out the column to edit from the x,y values of your mouse the code totals up the column widths to find an x value that matches entry of the bounds for the editable box your mouse clicked in. However, the first column width is already checked before it continues, when it continues it adds the first column width again before checking and therefore messes up if you have different column widths, so the line:

epos += this.Columns[i].Width;

simply needs changed to:
 

epos += this.Columns[i+1].Width;


Anyway, I have a small problem that has been bugging me for hours now and hope you can help. If the said ListView or any form control for that matter is larger than the size of the form, a scrollbar appears. Therefore when the user clicks on the screen you recieve the x,y coordinates from the top left of the form or part of the control that is visable (not sure myself) so.. is there a way to get the scrollbar offset so you can correctly determine the x,y coordinates even though a portion of the control is not visible?

Any help would be great and thanks for your time

Darren