需要实现效果:工具栏中按钮点击后下陷效果 需要实现:工具栏中A按钮点击后按钮A需下陷,点击工具栏上B按钮后B按钮需下陷,A显示正常,请问如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问题2:像vs.net2005开发工具中 工具-->选项中 左侧是操作目录树形菜单,右侧显示各操作内容,点其中一个菜单,右侧是切换form吗?要如果实现这种效果? click事件?click事件不能使它下陷。 如果你主要想实现一个类似的互拆效果,在两个按钮的CheckedChanged事件中判断该按钮是否选中,如果是就将另一个Checked置为false就可以了。如果你主要是想要“下陷”的那种视觉效果,你可能写点重绘代码(根据其是否选中)!对了,至于Click事件不能使它下陷,是不是没有设置CheckedOnClick? 你要是会Visible = false;你就明白了 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Windows.Forms.VisualStyles;namespace WindowsApplication153{ public partial class Form1 : Form { List<ToolStripButtonEx> Group = new List<ToolStripButtonEx>(); public Form1() { InitializeComponent(); ToolStrip TS = new ToolStrip(); TS.Parent = this; TS.RenderMode = ToolStripRenderMode.System; ToolStripButtonEx A = new ToolStripButtonEx(); A.DisplayStyle = ToolStripItemDisplayStyle.Text; A.Text = "AAA"; A.Click += new EventHandler(ToolStripButtonEx_Click); TS.Items.Add(A); Group.Add(A); ToolStripButtonEx B = new ToolStripButtonEx(); B.DisplayStyle = ToolStripItemDisplayStyle.Text; B.Text = "BBB"; B.Click += new EventHandler(ToolStripButtonEx_Click); TS.Items.Add(B); Group.Add(B); } void ToolStripButtonEx_Click(object sender, EventArgs e) { ToolStripButtonEx CurrentTSBEx = (ToolStripButtonEx)sender; foreach (ToolStripButtonEx TSBEx in Group) if (TSBEx != CurrentTSBEx) TSBEx.IsPressed = false; CurrentTSBEx.IsPressed = !CurrentTSBEx.IsPressed; } class ToolStripButtonEx : ToolStripButton { bool _IsPressed = false; public override bool Pressed { get { return IsPressed; } } public bool IsPressed { get { return _IsPressed; } set { _IsPressed = value; this.Invalidate(); } } } }} Nhibernate 对象作为数据源绑定DataGridView C# 程序偶尔出现 未处理ComException 向Excel写数据为什么说语法错误呢? 怎么判断数据集中是不是有数据? 关于新闻采集的问题 遇到学习C#以来第一个问题,望强人解决一下! c#控制台程序一问 求解 感谢此论坛 并能够讲解DataAdapter数据适配器实例问题 这个不明白 [插件]如何创建二级菜单 淘宝 添加SPM参数(模拟搜索进店) 将 Tooltip 显示在光标的左下角 未将对象引用设置到对象的实例
如果你主要是想要“下陷”的那种视觉效果,你可能写点重绘代码(根据其是否选中)!
对了,至于Click事件不能使它下陷,是不是没有设置CheckedOnClick?
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;namespace WindowsApplication153
{
public partial class Form1 : Form
{
List<ToolStripButtonEx> Group = new List<ToolStripButtonEx>(); public Form1()
{
InitializeComponent(); ToolStrip TS = new ToolStrip();
TS.Parent = this;
TS.RenderMode = ToolStripRenderMode.System; ToolStripButtonEx A = new ToolStripButtonEx();
A.DisplayStyle = ToolStripItemDisplayStyle.Text;
A.Text = "AAA";
A.Click += new EventHandler(ToolStripButtonEx_Click);
TS.Items.Add(A);
Group.Add(A); ToolStripButtonEx B = new ToolStripButtonEx();
B.DisplayStyle = ToolStripItemDisplayStyle.Text;
B.Text = "BBB";
B.Click += new EventHandler(ToolStripButtonEx_Click);
TS.Items.Add(B);
Group.Add(B);
} void ToolStripButtonEx_Click(object sender, EventArgs e)
{
ToolStripButtonEx CurrentTSBEx = (ToolStripButtonEx)sender; foreach (ToolStripButtonEx TSBEx in Group)
if (TSBEx != CurrentTSBEx)
TSBEx.IsPressed = false; CurrentTSBEx.IsPressed = !CurrentTSBEx.IsPressed;
} class ToolStripButtonEx : ToolStripButton
{
bool _IsPressed = false; public override bool Pressed
{
get
{
return IsPressed;
}
} public bool IsPressed
{
get
{
return _IsPressed;
} set
{
_IsPressed = value;
this.Invalidate();
}
}
}
}
}