久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <small id='ucNuS'></small><noframes id='ucNuS'>

        <bdo id='ucNuS'></bdo><ul id='ucNuS'></ul>
    1. <tfoot id='ucNuS'></tfoot>
      <legend id='ucNuS'><style id='ucNuS'><dir id='ucNuS'><q id='ucNuS'></q></dir></style></legend>
    2. <i id='ucNuS'><tr id='ucNuS'><dt id='ucNuS'><q id='ucNuS'><span id='ucNuS'><b id='ucNuS'><form id='ucNuS'><ins id='ucNuS'></ins><ul id='ucNuS'></ul><sub id='ucNuS'></sub></form><legend id='ucNuS'></legend><bdo id='ucNuS'><pre id='ucNuS'><center id='ucNuS'></center></pre></bdo></b><th id='ucNuS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ucNuS'><tfoot id='ucNuS'></tfoot><dl id='ucNuS'><fieldset id='ucNuS'></fieldset></dl></div>

      單擊控件內(nèi)的文本時(shí),用戶控件單擊事件不起作

      User control click event not working when clicking on text inside control?(單擊控件內(nèi)的文本時(shí),用戶控件單擊事件不起作用?)
    3. <small id='OySsI'></small><noframes id='OySsI'>

        <legend id='OySsI'><style id='OySsI'><dir id='OySsI'><q id='OySsI'></q></dir></style></legend>
            • <bdo id='OySsI'></bdo><ul id='OySsI'></ul>
                <tbody id='OySsI'></tbody>
              <tfoot id='OySsI'></tfoot>

                <i id='OySsI'><tr id='OySsI'><dt id='OySsI'><q id='OySsI'><span id='OySsI'><b id='OySsI'><form id='OySsI'><ins id='OySsI'></ins><ul id='OySsI'></ul><sub id='OySsI'></sub></form><legend id='OySsI'></legend><bdo id='OySsI'><pre id='OySsI'><center id='OySsI'></center></pre></bdo></b><th id='OySsI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OySsI'><tfoot id='OySsI'></tfoot><dl id='OySsI'><fieldset id='OySsI'></fieldset></dl></div>
                本文介紹了單擊控件內(nèi)的文本時(shí),用戶控件單擊事件不起作用?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

                我有一個(gè)名為 GameButton 的用戶控件,其中有一個(gè)標(biāo)簽.當(dāng)我將用戶控件添加到我的表單并為其添加一個(gè)單擊事件時(shí),它會(huì)在您單擊自定義按鈕的背景而不是標(biāo)簽中的文本時(shí)觸發(fā)?如果不在用戶控件代碼中添加一堆點(diǎn)擊事件,我將如何解決這個(gè)問題?

                UI 框架:winforms

                解決方案

                如果我對(duì)您的理解正確,您的 GameButton 用戶控件將在單擊時(shí)觸發(fā)該事件,但在單擊標(biāo)簽時(shí)不會(huì)觸發(fā)該事件——而您兩者都需要.這是因?yàn)闃?biāo)簽(控件)位于背景之上.因此,您還需要使用點(diǎn)擊事件注冊(cè)您的標(biāo)簽.這可以在設(shè)計(jì)器中手動(dòng)完成,也可以針對(duì)頁面上的每個(gè)控件以編程方式完成.

                如果您想在 UserControl 中執(zhí)行每個(gè)控件,請(qǐng)將其放入 UserControl 的 OnLoad 事件中,您可以為每個(gè)控件使用相同的單擊事件:

                foreach (var c in this.Controls)c.Click += new EventHandler(yourEvent_handler_click);public void yourEvent_handler_click(對(duì)象發(fā)送者,EventArgs e){//無論你想讓你的事件處理程序做什么}

                最好的方法是在用戶控件中創(chuàng)建單擊事件處理程序?qū)傩?這樣,每次您向用戶控件添加/刪除點(diǎn)擊事件時(shí),它都會(huì)自動(dòng)將其添加/刪除到用戶控件中的所有控件.

                public new event EventHandler Click {添加 {base.Click += 值;foreach(Controls 中的控制控件){control.Click += 值;}}消除 {base.Click -= 值;foreach(Controls 中的控制控件){control.Click -= 值;}}}

                這是另一個(gè)post:p>

                希望這會(huì)有所幫助!

                I have a user control called GameButton that has a label inside it. When I add the user control to my form, and add a click event to it, its triggered when you click on the background of the custom button, but not the text in the label? How would I fix this without adding a bunch of click events inside the user controls code?

                edit: UI framework: winforms

                解決方案

                If I am understanding you properly, your GameButton usercontrol will fire the event when clicked on, but not when the label is clicked on -- and you want both. This is because the label (a control) is on top of the background. Therefore, you need to register your label with the click event as well. This can be done manually in the designer or programmatically for each control on the page.

                If you want to do EVERY control in the UserControl, put this into the UserControl's OnLoad event and you can use the same click event for every control:

                foreach (var c in this.Controls)
                    c.Click += new EventHandler(yourEvent_handler_click);
                
                public void yourEvent_handler_click (object sender, EventArgs e){
                    //whatever you want your event handler to do
                }
                

                EDIT: The best way is to create the click event handler property in the user control. This way, every time you add/remove a click event to your user control, it adds/removes it to all the controls within the user control automatically.

                public new event EventHandler Click {
                        add {
                            base.Click += value;
                            foreach (Control control in Controls) {
                                control.Click += value;
                            }
                        }
                        remove {
                            base.Click -= value;
                            foreach (Control control in Controls) {
                                control.Click -= value;
                            }
                        }
                    }
                

                This is as per another post:

                Hope this helps!

                這篇關(guān)于單擊控件內(nèi)的文本時(shí),用戶控件單擊事件不起作用?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測(cè)有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運(yùn)行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)

                • <tfoot id='XqUcV'></tfoot>
                      <tbody id='XqUcV'></tbody>
                    <i id='XqUcV'><tr id='XqUcV'><dt id='XqUcV'><q id='XqUcV'><span id='XqUcV'><b id='XqUcV'><form id='XqUcV'><ins id='XqUcV'></ins><ul id='XqUcV'></ul><sub id='XqUcV'></sub></form><legend id='XqUcV'></legend><bdo id='XqUcV'><pre id='XqUcV'><center id='XqUcV'></center></pre></bdo></b><th id='XqUcV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XqUcV'><tfoot id='XqUcV'></tfoot><dl id='XqUcV'><fieldset id='XqUcV'></fieldset></dl></div>
                      <bdo id='XqUcV'></bdo><ul id='XqUcV'></ul>

                        <legend id='XqUcV'><style id='XqUcV'><dir id='XqUcV'><q id='XqUcV'></q></dir></style></legend>

                        <small id='XqUcV'></small><noframes id='XqUcV'>

                          主站蜘蛛池模板: 亚洲欧洲一区 | 国产精品久久久亚洲 | 超碰人人做 | 国产精品三级 | 亚洲国产精品视频一区 | 日韩中文在线观看 | 干干干操操操 | 亚洲精品乱码久久久久久蜜桃91 | 久久久精品视频免费看 | 在线视频一区二区三区 | 综合九九 | 精品国产高清一区二区三区 | 一区二区三区四区日韩 | 性色网站| 国产91在线视频 | 精品二区 | 91精品国产乱码久久久久久 | 欧美成人专区 | 在线视频 中文字幕 | 久久免费观看一级毛片 | 国产黄色在线观看 | 国产精品一区二区无线 | 亚洲国产精品久久久久久 | 久久一区| 亚洲精品中文字幕在线 | 久久免费精品视频 | 亚洲a视频 | 免费一级淫片aaa片毛片a级 | 精品美女视频在免费观看 | 亚洲日韩欧美一区二区在线 | 日日骚网 | 第一区在线观看免费国语入口 | 欧美精品成人一区二区三区四区 | 中文字幕在线看人 | 亚洲成人一区二区 | 国产精品av久久久久久久久久 | 九九福利| 欧美 日韩 视频 | 国产成人精品久久二区二区 | 日韩中文字幕在线视频 | 台湾av在线|