C# winForm程序 如何定义快捷健?

如按Ctrl+shift+S时调用指定方法…... 如按Ctrl+shift+S时调用指定方法… 展开
 我来答
wwwdbzynet
2008-11-19 · 超过23用户采纳过TA的回答
知道答主
回答量:57
采纳率:0%
帮助的人:70.6万
展开全部
if ((Keys.Shift & e.Modifiers) > 0 && (Keys.Control & e.Modifiers) > 0) //Control+Shift Key pressed
{
switch (e.KeyCode)
{
case Keys.H: //for topic shortkey verification and content replacement

//get selected text
//if no current text selection, create one by the position of current cursor
if (txtOutgoingBody.SelectedText == "")
{

//get current cursor postion
Int32 cursorpos = txtOutgoingBody.SelectionStart;
Int32 select_start;
Int32 select_end;
char[] chars = new char[] { ' ', '\n', '\r', '\t' };

if (cursorpos >= 0 && cursorpos <= txtOutgoingBody.TextLength)
{
if (cursorpos == 0)
select_start = 0;
else
{
//get select_start
select_start = txtOutgoingBody.Text.LastIndexOfAny(chars, cursorpos - 1);
if (select_start == -1)
select_start = 0;
else
select_start = select_start + 1;
}

//select_end
select_end = txtOutgoingBody.Text.IndexOfAny(chars, cursorpos);
if (select_end == -1)
select_end = txtOutgoingBody.TextLength - 1;
else
select_end = select_end - 1;

//select
txtOutgoingBody.Select(select_start, select_end - select_start + 1);

}

}

你看代码吧,然后记得给分!
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式