Visual Basic richtextbox滚动问题w10 [英] Visual basic richtextbox scrolling issue w10
问题描述
我想知道是否有人遇到过这个问题,并且可以对此有所了解。
VS1015,.net 4.0,.net 4.5和.net 4.6
我有一个包含许多控件的面板,这些控件都是以编程方式添加的。控件由标签,图片框,按钮和丰富的文本框组成。添加的控件数量可能会有所不同。
当我将鼠标悬停在面板上的任何控件上时,我可以使用鼠标滚轮滚动面板,除鼠标外 - 富文本框。当鼠标进入并离开富文本框但鼠标滚轮无效时,事件会触发。
此代码和滚动功能在Windows下完成并仍然可以正常工作7但是,在升级到W10的机器上,它没有。
添加RtxtBox示例
Dim AddTxtBoxEpDesc As RichTextBox
AddTxtBoxEpDesc = < span class =code-keyword>新 RichTextBox
使用 AddTxtBoxEpDesc
.Name = txtE
.Size = 新 Drawing.Size( 445 ,Args.hgtTxtOverview)
.Location = 新点( 212 ,thisEpisodeStartPos + Args.posPic - Math.Abs(myPanel.AutoScrollPosition.Y))
.Multiline = True
.WordWrap = True
.BackColor = Color.MintCream
.BorderStyle = BorderStyle.None
.Font = 新字体( < span class =code-string> arial, 8 ,FontStyle.Regular)
.Text = Args.Overview + Environment.NewLine + Environment.NewLine
.ScrollBars = RichTextBoxScrollBars.None
.Visible = True
结束 使用
AddHandler AddTxtBoxEpDesc.MouseEnter, AddressOf myPanel1_MouseEnter
AddHandler AddTxtBoxEpDesc.M ouseLeave, AddressOf myPanel1_MouseLeave
myPanel.Controls.Add(AddTxtBoxEpDesc)
事件。
<前lang =VB.NET> 私人 Sub myPanel1_MouseEnter( ByVal sender As System。 Object , ByVal e As EventArgs)
Dim myControl0 As Control = Me .Controls.Item( myPanel1)
myControl0.Focus()
结束 Sub
私人 Su b myPanel1_MouseLeave(发件人作为 对象,e 正如 EventArgs)
Me .ActiveControl = Nothing
结束 Sub
任何想法??
我尝试过:
我尝试过,仍然使用上面的代码。
我遇到了同样的问题:
私有 Sub RichTextBox_MouseWheel( ByVal 发件人作为 对象, ByVal e As System.Windows.Forms.MouseEventArgs) H andles RTB0m.MouseWheel,_
RTB1m.MouseWheel,RTB2m.MouseWheel,RTB3m.MouseWheel,RTB4m.MouseWheel,RTB5m.MouseWheel,RTB6m.MouseWheel,_
....
Dim rtbox As System.Windows.Forms.RichTextBox = sender
rtbox.Parent.Focus ()
结束 Sub
工作正常 vin 7 pro,但 win 10 它不 ...
我' v fixed / eluded / it如下:
.........
Dim pas As 整数 = Math.Round( Me .VerticalScroll.Maximum / 30 )
如果 e.Delta> 0 然后
如果 < span class =code-keyword> Me .VerticalScroll.Value< pas 然后
我 .VerticalScroll.Value = 0
Me .VerticalScroll.Value = 0
否则
我 .VerticalScroll.Value - = pas
我 .VerticalScroll.Value - = pas
结束 如果
其他
如果 我 .VerticalScroll.Value + pas> 我 .VerticalScroll.Maximum 然后
我.VerticalScroll.Value = Me .VerticalScroll.Maximum
Me .VerticalScroll.Value = 我 .VerticalScroll.Maximum
否则
我 .VerticalScroll.Value + = pas
我 .VerticalScroll.Value + = pas
结束 如果
结束 如果
结束 Sub
我希望帮助你!
I am wondering if anyone has encountered this issue and can shed some light on it.
VS1015, .net 4.0, .net 4.5 and .net 4.6
I have a panel with a number of controls that are all programmatically added. The controls consist of labels, picture boxes, buttons and rich textboxes. The number of the controls added can vary.
When I mouse over any of the controls on the panel I can scroll the panel with the mouse wheel, all except for mouse-over the rich textboxes. The events fire when the mouse enters and leaves the rich textboxes but the mouse wheel has no effect.
This code and the scrolling function did and still does work perfectly under Windows 7 however, on machines that have been upgraded to W10, it does not.
Add RtxtBox example
Dim AddTxtBoxEpDesc As RichTextBox
AddTxtBoxEpDesc = New RichTextBox
With AddTxtBoxEpDesc
.Name = txtE
.Size = New Drawing.Size(445, Args.hgtTxtOverview)
.Location = New Point(212, thisEpisodeStartPos + Args.posPic - Math.Abs(myPanel.AutoScrollPosition.Y))
.Multiline = True
.WordWrap = True
.BackColor = Color.MintCream
.BorderStyle = BorderStyle.None
.Font = New Font("arial", 8, FontStyle.Regular)
.Text = Args.Overview + Environment.NewLine + Environment.NewLine
.ScrollBars = RichTextBoxScrollBars.None
.Visible = True
End With
AddHandler AddTxtBoxEpDesc.MouseEnter, AddressOf myPanel1_MouseEnter
AddHandler AddTxtBoxEpDesc.MouseLeave, AddressOf myPanel1_MouseLeave
myPanel.Controls.Add(AddTxtBoxEpDesc)
The events.
Private Sub myPanel1_MouseEnter(ByVal sender As System.Object, ByVal e As EventArgs)
Dim myControl0 As Control = Me.Controls.Item("myPanel1")
myControl0.Focus()
End Sub
Private Sub myPanel1_MouseLeave(sender As Object, e As EventArgs)
Me.ActiveControl = Nothing
End Sub
Any ideas??
What I have tried:
I have tried and still using the code above.
Hi, i had the same problem: Private Sub RichTextBox_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RTB0m.MouseWheel, _ RTB1m.MouseWheel, RTB2m.MouseWheel, RTB3m.MouseWheel, RTB4m.MouseWheel, RTB5m.MouseWheel, RTB6m.MouseWheel, _ .... Dim rtbox As System.Windows.Forms.RichTextBox = sender rtbox.Parent.Focus() End Sub That worked fine with vin 7 pro, but with win 10 it does not... I'v fixed /eluded/ it as follows: ......... Dim pas As Integer = Math.Round(Me.VerticalScroll.Maximum / 30) If e.Delta > 0 Then If Me.VerticalScroll.Value < pas Then Me.VerticalScroll.Value = 0 Me.VerticalScroll.Value = 0 Else Me.VerticalScroll.Value -= pas Me.VerticalScroll.Value -= pas End If Else If Me.VerticalScroll.Value + pas > Me.VerticalScroll.Maximum Then Me.VerticalScroll.Value = Me.VerticalScroll.Maximum Me.VerticalScroll.Value = Me.VerticalScroll.Maximum Else Me.VerticalScroll.Value += pas Me.VerticalScroll.Value += pas End If End If End Sub I hope that help you!
这篇关于Visual Basic richtextbox滚动问题w10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!