找到ToolStripItem在ToolStrip控件中的索引位置
2015-12-14 17:26:47 访问(2259) 赞(0) 踩(0)
/// <summary>
/// 找到ToolStripItem在ToolStrip控件中的索引位置
/// </summary>
/// <param name="ts"></param>
/// <param name="tsi"></param>
/// <returns></returns>
public int ToolStripFindToolStripItemIndex(ToolStrip ts, ToolStripItem tsi)
{
if (ts == null)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "传入参数:"
+ "ToolStrip ts"
+ "为null。"
);
}
if (tsi == null)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "传入参数:"
+ "ToolStripItem tsi"
+ "为null。"
);
}
int iCount = ts.Items.Count;
for (int i = 0; i < iCount; ++i)
{
if (tsi == ts.Items[i])
return i;
}
return -1;
}
标签:
常用代码 


ToolStrip 


ToolStripItem 


位置索引 


上一条:
下一条:
相关评论
发表评论