Splitter withhidden left control

xiaoxiao2021-03-06  42

There is a button in the middle of the splitter in some software. You can display / hide the control on the left, such as WPS. One is also customized in .NET. Class code: public class mysplitter

Public Shared Sub AddShowHideEvent (ByVal sl As Splitter) Dim lbl As New Label lbl.Text = "3" lbl.Font = New System.Drawing.Font ( "Marlett", 7.0 !, System.Drawing.FontStyle.Regular, System. Drawing.graphicsUnit.point, ctype (2, byte)) lbl.autosize = true lbl.location = new point (-3.5, sl.height / 2 - lbl.height) lbl.cursor = curs.hand lbl.forecolor = Color .Red sl.controls.add (lbl) sl.Width = 3.5

AddHandler LBL.Click, Addressof LBL_Click AddHandler Sl.resize, Addressof Splitter_Resize

DIM TT AS New Tooltip Tt.SetTooltip (LBL, "Hide Controls") LBL.TAG = TT End Sub

Private Shared Sub lbl_Click (ByVal sender As Object, ByVal e As System.EventArgs) Dim lbl As Label = CType (sender, Label) Dim targetctrl As Control Dim sl As Splitter = CType (lbl.Parent, Splitter) Dim pctrl As Control = Sl.parent

For Each Temp as Control in PCTRL.CONTROLS IF NOT TEMP.EQUALS (SL) Then if sl.dock = dockstyle.left dam = DockStyle.left andalso _ (not temp.visible orelse temp.left

Private Shared Sub splitter_Resize (ByVal sender As Object, ByVal e As System.EventArgs) Dim sl As Splitter = CType (sender, Splitter) Dim lbl As Label = sl.Controls (0) lbl.Location = New Point (-3.5, sl . HEIGHT / 2 - LBL.HEIGHT) End Subend Class When using, add the red code as shown below in the initialization code of the form: public subnewash () mybase.new ()

'This call is required for the Windows Form Designer. InitializeComponent ()

'Add any initialization mysplitter.addshowhideEvent (me.splitter1) End Sub after INITIALIZECOMPONENT () call

转载请注明原文地址:https://www.9cbs.com/read-54043.html

New Post(0)