[Closed] mouse wheel
Hello Guys!
Anyone knows how to Whell two dotnet listviews at once???
I want to wheel one list and automatically the other one.
i have this:
on myListview MouseWheel events do
(
--I dont know how to pass the events to the other listview
)
thanks.
Eduardo,
I think the best solution for UI interaction would be to change the SelectedIndices or SelectedItems value. This way the ScrollBar will be updated automatically.
if you don’t want to check the selection, and presuming both listviews are of the same size (scrolling in tandem makes me think they are), then you might be able to get the current scroll amount for one listview, then apply the same scroll amount to the other.
I thought about that also but it seems you can only do that with a ScrollBar control. There’s no way to get ListView ScrollBar or Scroll value.
thanks ypuech, but i don’t know how to control the scrolling of a listview for an ScrollBar control, what are the methods to use? I can’t find any reference
thanks again
As I said in my previous post, there’s no way to get ListView ScrollBar or Scroll value.
But why do you want to scroll two ListViews at the same time ?
well, i’m creating a tool to connect automatically facial animation shapes and morpher channels. Then, in the second listview i want to show the morpher channels and in the first listview i want to show the matching shape. So if I scroll one of the listviews i need to scroll the other one.
I have two listviews because the tool specifications say that each listview is located in a different rollout. the rollouts move at once and one is just on the left from the other.
any idea of what can i do??
thanks
In fact, I’ve never seen a control updating its Scroll value without mouse Wheel event in it.
But you can update a ListView when in the other, a ListView item is selected. This way, the UI will be easier to understand by the user.
i’ve implemented that functionality yet. but thanks anyway. sorry for wasting your time with things that are not possible to do. jeje.
Thanks again.
I’ve found a way but I dont think it’s the best way yet, but it does the job. From what I’ve read to control the scrollbars in the listview we need to dive into the windows API and so on… Anyway, here’s an example, using EnsureVisible.
(
local hForm = dotNetObject "MaxCustomControls.MaxForm"
hForm.Size = dotNetObject "System.Drawing.Size" 640 480
hForm.FormBorderStyle = (dotnetclass "System.Windows.Forms.FormBorderStyle").FixedToolWindow
hForm.Text = ""
hForm.ShowInTaskbar = False
local txtbox = dotNetObject "System.Windows.Forms.TextBox"
txtbox.location=dotNetObject "System.Drawing.Point" 10 10
local txtbox2 = dotNetObject "System.Windows.Forms.TextBox"
txtbox2.location=dotNetObject "System.Drawing.Point" 10 40
local cmbbox = dotNetObject "System.Windows.Forms.ComboBox"
cmbbox.location=dotNetObject "System.Drawing.Point" 10 80
local lstview1 = dotNetObject "System.Windows.Forms.ListView"
lstview1.location=dotNetObject "System.Drawing.Point" 200 10
lstview1.name="lstview1"
local lstview2 = dotNetObject "System.Windows.Forms.ListView"
lstview2.location=dotNetObject "System.Drawing.Point" 400 10
lstview2.name="lstview2"
local dnKeys=dotnetclass "System.Windows.Forms.Keys"
hform.controls.add(txtbox)
hform.controls.add(txtbox2)
hform.controls.add(cmbbox)
hform.controls.add(lstview1)
hform.controls.add(lstview2)
seed(timestamp())
for i=1 to 20 do
(
lstview1.items.add ((random 1 256) as string)
lstview2.items.add ((random 1 256) as string)
)
local theKey=false
fn txtbox_KeyDown sender eb =
(
if (eb.Keycode==dnKeys.Tab) OR (eb.Keycode==dnKeys.Return) then theKey=eb.KeyCode else theKey=false
)
fn txtbox_KeyPress sender eb =
(
if theKey!=false then
(
case theKey of
(
(dnKeys.Tab): hform.selectnextcontrol hform.ActiveControl true true false false
(dnKeys.Return): print "Return"
)
)
)
local lstindex=0
fn lstview1_MouseWheel sender eb =
(
eb.handled=true
if eb.delta<0 then
(
if lstindex+1<sender.items.count then
(
lstindex+=1
lstview1.ensurevisible lstindex
lstview2.ensurevisible lstindex
)
)
else
(
if lstindex-1>0 then
(
lstindex-=1
lstview1.ensurevisible lstindex
lstview2.ensurevisible lstindex
)
)
)
dotnet.addEventHandler txtbox "KeyDown" txtbox_KeyDown
dotnet.addEventHandler txtbox "KeyPress" txtbox_KeyPress
dotnet.addEventHandler txtbox2 "KeyDown" txtbox_KeyDown
dotnet.addEventHandler txtbox2 "KeyPress" txtbox_KeyPress
dotnet.addEventHandler lstview1 "MouseWheel" lstview1_MouseWheel
hForm.ShowModeless()
)
PS- Sorry it has some other code I’ve used for the TAB handling in another example