为什么设置分离器的位置如此困难?

编程入门 行业动态 更新时间:2024-10-26 04:21:10
本文介绍了为什么设置分离器的位置如此困难?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 下面给出的代码内容;需要3个面板和2个分离器。但是,第二个分离器(绿色)必须位于灰色和棕色面板之间。但不是在正确的地方。有什么建议吗?谢谢。

Hi everyone, The content of the codes given below; 3 panels and 2 Splitter are required. However, the 2nd splitter (Green) must be located between the gray and brown panel. But not in the right place. Are there any suggestions? Thanks.

Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Show() Dim tmpSplitter As Splitter Dim tmpPanel As Panel Dim MainPanel As Panel ' This is main panel ' MainPanel = New Panel With MainPanel .Name = "MainPanel" .Dock = DockStyle.Fill .BackColor = Color.LightGray .BorderStyle = BorderStyle.Fixed3D .Visible = True End With Me.Controls.Add(MainPanel) ' 1: First Top Panel and Splitter ' tmpPanel = New Panel With tmpPanel .Name = "Panel1" .Dock = DockStyle.Top .BackColor = Color.Red .Visible = True End With tmpSplitter = New Splitter With tmpSplitter .Name = "Split1" .Dock = DockStyle.Top .BackColor = Color.Blue .Cursor = Cursors.HSplit End With Me.Controls.Add(tmpSplitter) Me.Controls.Add(tmpPanel) ' 2: Second Panel added to the left side of the main panel ' MainPanel.Dock = DockStyle.Right MainPanel.Size = New Size(MainPanel.Width * 0.5, MainPanel.Height) Dim btn As New Button btn.Size = New Size(10, 50) btn.Location = New Point(MainPanel.Location.X - btn.Width, MainPanel.Location.Y) Me.Controls.Add(btn) tmpPanel = New Panel With tmpPanel .Size = New Size(10, MainPanel.Height) .Location = New Point(MainPanel.Location.X - .Width - 5, MainPanel.Location.Y) .Name = "Panel2" .Dock = DockStyle.Fill .BackColor = Color.Brown End With ' THIS SPLITTER IS NOT IN THE RIGHT PLACE. Must be between brown and gray panel ' tmpSplitter = New Splitter With tmpSplitter .Size = New Size(5, MainPanel.Height) .Location = New Point(MainPanel.Location.X - .Width, MainPanel.Location.Y) .Name = "Split2" .Dock = DockStyle.Right .BackColor = Color.Green .Cursor = Cursors.VSplit End With Me.Controls.Add(tmpSplitter) Me.Controls.Add(tmpPanel) End Sub End Class

我尝试过: 我改变了Splitter的位置,但这并非毫无意义。它可以在设计阶段手动完成,但在运行时无法使用代码完成。

What I have tried: I changed the location of Splitter, but it wasn't meaningless. It can be done manually during the design phase, but it cannot be done with code at run time.

推荐答案

只需使用SplitContainer而不是Splitter并使用面板它已经在使用了。这样,整个拆分器处理就完成了。 Just use a SplitContainer instead of a Splitter and use the Panels that it's already working with. That way, the whole splitter handling is done for you.

大家好,多一点研究并尝试解决方案 Hi everyone, a little more research and try to solve the solution Me.Controls.SetChildIndex (tmpSplitter, 0)

足以在最后一行写入。感谢您的贡献

is enough to write on the last line. Thank you for your contributions

更多推荐

为什么设置分离器的位置如此困难?

本文发布于:2023-11-25 07:30:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628868.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分离器   困难   位置

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!