如何调用事件处理程序,例如“Click”?一个完全不同的对象方法条件语句? [英] How do I call an event handler such as "Click" to a completely different object methods conditional statement?

查看:51
本文介绍了如何调用事件处理程序,例如“Click”?一个完全不同的对象方法条件语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我的第一篇文章。所以我为任何撤消帖子道歉。

另外,我还在学习编码。随着学习C#作为一种语言。我的语法知识有限。 

First, This is my first post. So I apologize for any undoing of postings.
Also, I am still learning to code. Along with learning C# as a language. My syntax knowledge is limited. 

我需要帮助尝试从我的Windows窗体应用程序中的各种对象调用数据,以用于生成最终结果。 

I need help trying to call the data from various objects in my windows form application to be used to generate the final result. 

现在我对它进行了编码,以便它们都响应计算按钮。但我似乎无法回忆起最终用户的实际选择。它只是简单地计算并显示每种行李类型的每个潜在结果,以达到运费
的费率。 @ _ @

Right now I have it coded so that they all respond to the calculate button. But I cant quite seem to get this to recall the actual selection the end user made. It just simply calculates and displays every potential result for each bag type, for reach shipping rate. @_@




我不知道用什么语法从1调用点击事件(Combobox)选择包类型),2(radiobutton),2A(RadioButton2),2B(RadioButton3)在我的计算按钮中使用。 此外,我不知道如何将事件转换为bool for
为我的计算按钮创建一个If循环。

I have no Idea what syntax's to use to call the click events from 1(Combobox to select the bag type), 2(radiobutton), 2A(RadioButton2), 2B (RadioButton3) to use in my Calculate button.  Furthermore I do not know how to convert an event to a bool for an If loop to be created for my calculate button.

我当前的If循环代码如下:

My current If loop code is as follows:

//在循环之前。



//Prior to the loop.

推荐答案



嗨Wren Ryiuu,


Hi Wren Ryiuu,

>>我不知道用什么语法来调用点击事件从1(Combobox选择行李类型),2(radiobutton),2A(RadioButton2),2B(RadioButton3)到在我的计算按钮中使用。 

您可以使用一些事件来调用Calc_button_On_Click envet。

You can use some Events to call Calc_button_On_Click envet.

     public void Calc_button_On_Click(object sender, EventArgs e)
        {
           //Do some data operations
        }

        //Combobox
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Calc_button_On_Click(sender , e);
        }

        //RadioButton
        private void radioButton1_EnabledChanged(object sender, EventArgs e)
        {
            Calc_button_On_Click(sender, e);
        }



>>此外,我不知道如何将事件转换为bool,为我的计算按钮创建一个If循环。

您可以尝试以下方式转换事件bool。

You can try the following way to convert an event to a bool.

        public bool calculateFuction(string par1)
        {
            bool result = false;
            if (par1 == "")
            {
                return result = true;
            }
            //....if
            return result;
        }

如果我有任何误解,您可以为其他任何人提供所有必要的代码段。从头开始重现您的问题以及有关结果的详细说明,包括任何异常消息。

If I have any misunderstanding, you can include all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.

最好的问候,

Yohann Lu

Yohann Lu


这篇关于如何调用事件处理程序,例如“Click”?一个完全不同的对象方法条件语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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