Keypress vs Mouseclick [英] Keypress vs Mouseclick

查看:97
本文介绍了Keypress vs Mouseclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i need your assistance with the following topic:

i need find out how change this procedure from keypress to mouseclick properly
make static binding: now this app is getting key_bindings values from database.
here is code for keypress event:







private void Question_KeyDown(object sender, KeyEventArgs e)
{
int? nullable = new int?();
this.qta.get_answer_number_by_key(new int?(e.KeyValue), ref nullable);
if (!nullable.HasValue)
{
    this.SwitchQuestion(e.KeyValue);
}
else
{
    int? nullable5 = nullable;
    nullable = nullable5.HasValue ? new int?(nullable5.GetValueOrDefault() - 1) : new int?();
    bool? nullable2 = new bool?(false);
    bool? end = new bool?(false);
    int count = this.pnlAnswers.Controls.Count;
    nullable5 = nullable;
    nullable5 = nullable5.HasValue ? new int?(nullable5.GetValueOrDefault() + 1) : new int?();
    if ((count >= nullable5.GetValueOrDefault()) && nullable5.HasValue)
    {
        Valid valid;
        int? tag = (int?) this.pnlAnswers.Controls[nullable.Value].Tag;
        this.qta.test_answer(this.q, tag, ref nullable2, ref end, ref this.pass);
        this.e = end.Value;
        if (nullable2.Value)
        {
            valid = new Valid(MessageType.Valid);
        }
        else
        {
            valid = new Valid(MessageType.Invalid);
        }
        valid.ShowDialog();
        base.Close();
    }
}
}





非常感谢你的时间和对新手的支持:)



thanks a lot for your time and support for newbies :)

推荐答案

与KeyPress事件类似,控件具有MouseClick事件。请参阅 http://msdn.microsoft。 com / en-us / library / system.windows.forms.control.mouseclick(v = vs.110).aspx [ ^ ]



我建议将代码移动到KeyPress和MouseClick都可以调用而不是复制代码的函数中。
Similar to the KeyPress event, controls have a MouseClick event. See http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mouseclick(v=vs.110).aspx[^]

I would suggest moving the code into a function that both KeyPress and MouseClick can call instead of duplicating your code.


这篇关于Keypress vs Mouseclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆