简体   繁体   English

c#中可调整大小的表格布局面板

[英]Resizable table layout panel in c#

I find the table layout panel in c# (.net 2.0) to be very primitive. 我发现c#(。net 2.0)中的表格布局面板非常原始。 I wanted to allow my users to resize the columns in a table layout panel but there are no ready made options to do so. 我想允许我的用户调整表格布局面板中的列的大小,但是没有现成的选项可以这样做。 Is there a way atleast to find out whether the cursor is directly over any borders of a cell and if so, which cell is beneath it ?? 有没有办法找出光标是否直接在一个单元格的任何边界上,如果是这样,哪个单元格在它下面? May be having this information, we can atleast try resizing that row/column thru' code. 可能有这些信息,我们至少可以尝试通过'代码调整行/列的大小。 Help me finding, 帮我找到,

  • whether the cursor is directly over any borders of a cell 光标是否直接位于单元格的任何边框上
  • which cell is beneath it (applicable only if the first question has an answer) 哪个单元格位于其下方(仅在第一个问题有答案时适用)

Many Thanks, 非常感谢,

Sudarsan Srinivasan Sudarsan Srinivasan

If your layout is not overly complex, maybe you can achieve what you want by using SplitContainer controls? 如果你的布局不是太复杂,也许你可以通过使用SplitContainer控件实现你想要的? Unfortunately, each SplitContainer will have only two "cells", but you can embed a SplitContainer in another SplitContiner panel to get more resizable cells: 不幸的是,每个SplitContainer只有两个“单元格”,但您可以在另一个SplitContiner面板中嵌入SplitContainer以获得更多可调整大小的单元格:

┌──────────────────┐
│┌─────┬──────────┐│
││     │          ││
││     │          ││
│└─────┴──────────┘│
├──────────────────┤
│┌──────────┬─────┐│
││          │     ││
││          │     ││
│└──────────┴─────┘│
└──────────────────┘

OK, so ASCII art was never one of my stronger skills, but I think you get the point ;o) 好的,所以ASCII艺术从来都不是我强大的技能之一,但我认为你明白了这一点; o)

Building on top of @Fredrik Mörk's solution : 建立在@FredrikMörk的解决方案之上:

After embedding another SplitContainer(s), the only drawback is that they don't automatically resize together, so you quickly lose the tabular view. 嵌入另一个SplitContainer之后,唯一的缺点是它们不会自动调整大小,因此您很快就会丢失表格视图。 A solution could be to set up a SplitterMoved event handler for every applicable SplitContainer: 解决方案可能是为每个适用的SplitContainer设置SplitterMoved事件处理程序:

private void mySplitContainer_SplitterMoved(object sender, SplitterEventArgs e) {
  mOtherySplitContainer.SplitterDistance = e.SplitX;
}

If your SplitContainer is horizontal use e.SplitX , if it's vertical use e.SplitY . 如果您的SplitContainer是水平使用e.SplitX ,如果它是垂直使用e.SplitY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM