久久久久久久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>

      單擊控件內的文本時,用戶控件單擊事件不起作

      User control click event not working when clicking on text inside control?(單擊控件內的文本時,用戶控件單擊事件不起作用?)
    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>
                本文介紹了單擊控件內的文本時,用戶控件單擊事件不起作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個名為 GameButton 的用戶控件,其中有一個標簽.當我將用戶控件添加到我的表單并為其添加一個單擊事件時,它會在您單擊自定義按鈕的背景而不是標簽中的文本時觸發?如果不在用戶控件代碼中添加一堆點擊事件,我將如何解決這個問題?

                UI 框架:winforms

                解決方案

                如果我對您的理解正確,您的 GameButton 用戶控件將在單擊時觸發該事件,但在單擊標簽時不會觸發該事件——而您兩者都需要.這是因為標簽(控件)位于背景之上.因此,您還需要使用點擊事件注冊您的標簽.這可以在設計器中手動完成,也可以針對頁面上的每個控件以編程方式完成.

                如果您想在 UserControl 中執行每個控件,請將其放入 UserControl 的 OnLoad 事件中,您可以為每個控件使用相同的單擊事件:

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

                最好的方法是在用戶控件中創建單擊事件處理程序屬性.這樣,每次您向用戶控件添加/刪除點擊事件時,它都會自動將其添加/刪除到用戶控件中的所有控件.

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

                這是另一個post:p>

                希望這會有所幫助!

                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!

                這篇關于單擊控件內的文本時,用戶控件單擊事件不起作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

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

                          主站蜘蛛池模板: 日本一区二区不卡 | 中文字幕中文字幕 | 男女羞羞视频在线观看 | aaaaaaa片毛片免费观看 | 成人精品鲁一区一区二区 | 日韩一级 | 久草网站 | 99福利视频 | 中文字幕亚洲一区 | 亚洲电影成人 | 国产一区二区久久 | 精品一区在线 | 国产成人在线视频免费观看 | 久久久91精品国产一区二区三区 | 国产精品久久亚洲 | 91视在线国内在线播放酒店 | 国产精品久久 | www国产精| 国产亚洲成av人片在线观看桃 | 麻豆av在线免费观看 | 成人做爰9片免费看网站 | 国产剧情一区 | 欧美激情一区二区 | 免费看a| 中文字幕第100页 | 中文字幕二区 | 国产精品av久久久久久久久久 | 成人久久一区 | 中文字幕成人在线 | 久久久久久久网 | 日韩精品在线一区 | 美女视频一区二区三区 | 国产精品美女一区二区三区 | 久久av在线播放 | 狠狠操狠狠操 | 国产黄色精品 | 欧美久久免费观看 | 日韩毛片网 | 日韩成人免费在线视频 | 亚洲精品91| 视频一区二区在线观看 |