救命啊,控件停靠问题。
我想实现象outlook那样的导航栏,部分代码如下:
private string[] strNavigateButtons = new string[]
{"文件夹浏览","我的图片收藏","日历和时间"};
private string[] strNavigateButtonsNames = new string[]{"nbFolderBrowse","nbMyPicture","nbDateTime"};
private NavigateButton[] nbs = new NavigateButton[3];
/*导航栏按狃
NavigateButtonIsClicked和NavigateButtonIsTop是自定义类NavigateButton的公共属性,指示按钮是否位于导航栏上部,是否被按下
*/
for(int i = 0; i< 3; i++)
{
nbs[i] = new NavigateButton();
nbs[i].Text = strNavigateButtons[i];
nbs[i].Name = strNavigateButtonsNames[i];
nbs[i].Parent = panelNavigateBar;
nbs[i].Height = 12;
nbs[i].Dock = DockStyle.Top;
nbs[i].NavigateButtonIsTop = true;
nbs[i].Click += new EventHandler(NavigateButtonOnClick);
}
nbs[0].NavigateButtonIsClicked = true;
nbs[1].NavigateButtonIsClicked = false;
nbs[2].NavigateButtonIsClicked = false;
private void NavigateButtonOnClick(object obj, EventArgs ea)
{
int index = 0;
NavigateButton nbClicked = (NavigateButton)obj;
for(index = 0; index < nbs.Length; index++)
{
if (nbs[index] == nbClicked)
{
break;
}
}
if(nbClicked.NavigateButtonIsTop == true)
if(nbClicked.NavigateButtonIsClicked == false)
{
for(int i = index - 1; i > -1; i--)
{
nbs[i].Dock = DockStyle.Bottom;
nbs[i].NavigateButtonIsTop = false;
}
}
else
return;
else
for(int i = index; i < nbs.Length; i++)
{
nbs[i].Dock = DockStyle.Top;
nbs[i].NavigateButtonIsTop = true;
}
foreach(NavigateButton bn in nbs)
bn.NavigateButtonIsClicked = false;
nbClicked.NavigateButtonIsClicked = true;
}
下面的那段代码好象有问题,老是停靠顺序不对。我仔细看了一下,也没发现什么问题。
for(int i = index - 1; i > -1; i--)
{
nbs[i].Dock = DockStyle.Bottom;
nbs[i].NavigateButtonIsTop = false;
}
问题点数:20、回复次数:4Top
1 楼nxct(老猫)回复于 2003-11-04 20:53:49 得分 2
帮你 upTop
2 楼kuangren(J※『一失足成千古恨,再回头已百年身』)回复于 2003-11-04 23:07:35 得分 15
这个不是我写的,不过你可以参考
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
/*
* 算法简述(主要分为如下三个步骤):
*
* 1、首先将该按钮上面的按钮推上去(相当于点击被“推上去”的这个按钮),在推动的过程中,
* 如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 1)
* 2、然后将自己推上去
* 3、最后将该按钮下面的按钮推下去(相当于点击被“推下去”的这个按钮),在推动的过程中,
* 如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 3)
*
* 整个过程就像你站在队伍中,你想前进,首先你得告诉站在你前面的人前进,然后你必须等待,直到你前面的人
* 前进之后你才能够前进。(你前面的人同样必须和你做同样的事,这个过程直到传达到第一个人为止)
*
*
*
* 还没有明白吗?没关系,我们来举例说明这个算法:
* 为了方便理解程序,我们以“按钮1”、“按钮2”、“按钮3”和“按钮4”这四个从上到下依次排列的按钮为例,
* 我们假设“按钮3”被点击:
* 1、将“按钮1”推到最顶端
* 2、将“按钮2”推到“按钮1”的下方。
* 3、将自己(“按钮3”)推上去;
* 4、将“按钮4”推下去。
*
*
* 本程序中主要运用了属性的特点。
* 因为使用的是中文编程,所以就不再详细说明了。
*/
namespace QQ3000
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button 按钮_我的好友;
private System.Windows.Forms.Button 按钮_陌生人;
private System.Windows.Forms.Button 按钮_黑名单;
private int 陌生人
{
get
{
return 按钮_陌生人.Top;
}
set
{
if( value < 按钮_陌生人.Top )
{
按钮_陌生人.Top = 按钮_我的好友.Top + 按钮_我的好友.Height;
}
else
{
黑名单 ++;
按钮_陌生人.Top = 按钮_黑名单.Top - 按钮_陌生人.Height;
}
}
}
private int 黑名单
{
get
{
return 按钮_黑名单.Top;
}
set
{
if( value < 按钮_黑名单.Top )
{
陌生人 --;
按钮_黑名单.Top = 按钮_陌生人.Bottom + 1;
}
else
{
按钮_黑名单.Top = groupBox1.Height - 按钮_陌生人.Height;
}
}
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.按钮_黑名单 = new System.Windows.Forms.Button();
this.按钮_陌生人 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.按钮_我的好友 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// 按钮_黑名单
//
this.按钮_黑名单.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.按钮_黑名单.Location = new System.Drawing.Point(0, 48);
this.按钮_黑名单.Name = "按钮_黑名单";
this.按钮_黑名单.Size = new System.Drawing.Size(97, 24);
this.按钮_黑名单.TabIndex = 2;
this.按钮_黑名单.Text = "黑 名 单";
this.按钮_黑名单.Click += new System.EventHandler(this.按钮_黑名单_单击);
//
// 按钮_陌生人
//
this.按钮_陌生人.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.按钮_陌生人.Location = new System.Drawing.Point(0, 24);
this.按钮_陌生人.Name = "按钮_陌生人";
this.按钮_陌生人.Size = new System.Drawing.Size(97, 24);
this.按钮_陌生人.TabIndex = 1;
this.按钮_陌生人.Text = "陌 生 人";
this.按钮_陌生人.Click += new System.EventHandler(this.按钮_陌生人_单击);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.按钮_黑名单,
this.按钮_陌生人,
this.按钮_我的好友});
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(97, 352);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// 按钮_我的好友
//
this.按钮_我的好友.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.按钮_我的好友.Name = "按钮_我的好友";
this.按钮_我的好友.Size = new System.Drawing.Size(97, 24);
this.按钮_我的好友.TabIndex = 0;
this.按钮_我的好友.Text = "我 的 好 友";
this.按钮_我的好友.Click += new System.EventHandler(this.按钮_我的好友_单击);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(113, 378);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "QQ3000";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void 按钮_我的好友_单击(object sender, System.EventArgs e)
{
陌生人 ++;
}
private void 按钮_陌生人_单击(object sender, System.EventArgs e)
{
陌生人 --;
黑名单 ++;
}
private void 按钮_黑名单_单击(object sender, System.EventArgs e)
{
陌生人 --;
黑名单 --;
}
}
}
Top
3 楼fgc5201314(成成(努力中...))回复于 2003-11-05 09:59:42 得分 3
上面的程序叫QQ3000~~~
其实实现这个功能用outlookBar或janus控件就很容易实现了~~
Top
4 楼zz_guang(广)回复于 2004-03-23 11:47:07 得分 0
请问谁有 outlookbar 控件,能否给我发一个?
email_2002@etang.comTop
相关问题
- 如何实现panel等控件的多边停靠?????
- 求停靠工具栏思路,代码,或者现有控件
- 怎样使控件的大小随窗体的改变而改变,就是控件的停靠
- 我在窗口停靠了个CControlBar控件,双击控件边框控件变成浮动状态,如何去掉浮动状态呢?
- **DockPresident**,世界上功能最强大的停靠(Docking)控件,超级酷,支持多种停靠风格,拥有了她,您就可以作出Visual C++,Visual Inter
- 如何用VB实现停靠窗体(DOCKING)和工具条?有好用的控件吗?
- 一个关于拖动控件时通过坐标决定停靠的问题。我百思不得其解。。。。
- 含有TreeView的窗体停靠到一个控件上产生TreeView的Deletion事件,怎么处理?
- 怎样在一个form窗体中怎样实现停靠在某一侧的panel或tab控件隐藏或显示,就像vs ide的工具栏一样?
- 控件!!!




