Home > Net >  C # Winfom how to get control of position, and determine whether arrived at the bottom of the scroll
C # Winfom how to get control of position, and determine whether arrived at the bottom of the scroll

Time:09-25

The following code:



[DllImport (" user32. DLL, "EntryPoint=" GetScrollPos ")]
Public static extern int GetScrollPos (IntPtr HWND, int nBar);

Private void button1_Click (object sender, EventArgs e)
{
//one. Get the position of the vertical scroll bar
Int I=GetScrollPos (enclosing listView1. Handle, 1);

//2. The difficulty in this step, how to achieve a listView1 controls the length of the scroll bar area
int b=1;

Judging//3.
If (I==b)
{
MessageBox. Show (" bottom ");
}
}

Through the first step to get to the position of the scroll bar, the difficulty in the second part, how to know the position is located in the bottom of the control?

I want to achieve a result, is to realize the text frame's refresh, if the position is located in the bottom of the scroll bar, I'll focus will automatically update to the latest text, if the position is not in at the bottom of the scroll bar (is drag the scroll bar to view the front data), I will not update the focus,

To achieve this effect must be able to real-time to determine whether a scroll bar at the bottom, consult everybody a great god,

CodePudding user response:

Pull the scroll bar to the bottom, see
 GetScrollPos (this) listView1) Handle, 1) 
the value of the len, if less than I len is not the end

CodePudding user response:

reference 1st floor lovelj2012 response:
pull the scroll bar to the bottom, see
 GetScrollPos (this) listView1) Handle, 1) 
the value of the len, if less than I len is not exactly luo


I mean don't scroll to the bottom to get to the value of the I

CodePudding user response:

My suggestion, and you don't get to the bottom, not conflict,

You first make it to the bottom, when acquiring the values, such as len, that is to say as long as GetScrollPos (this. ListView1. Handle, 1) is not equal to len, is certainly not the bottom,

CodePudding user response:

When the scroll bar in the end, if the current position value + step the biggest shift=length,

CodePudding user response:

 
///& lt; Summary>
///get the scroll bar range
///& lt;/summary>
[DllImport (" user32. DLL, "EntryPoint=" GetScrollRange CharSet=CharSet. Auto)]
Public static extern int GetScrollRange (IntPtr HWND, int nBar, out int minPos, out int maxPos);


https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getscrollrange
  •  Tags:  
  • C#
  • Related