日期:2014-05-17 浏览次数:21122 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (ToolStripItem item in menuStrip1.Items)
{
EnumChildMenu(item);
}
}
private void EnumChildMenu(ToolStripItem tsi)
{
OnFind(tsi);
if (tsi is ToolStripMenuItem)
{
ToolStripMenuItem tsmi = tsi as ToolStripMenuItem;
foreach (ToolStripItem item in tsmi.DropDownItems)
{
EnumChildMenu(item);
}
}
}
private void OnFind(ToolStripItem tsi)
{
tsi.BackColor = Color.Blue;
}
}
}