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

<small id='7gFFv'></small><noframes id='7gFFv'>

    <bdo id='7gFFv'></bdo><ul id='7gFFv'></ul>
  • <legend id='7gFFv'><style id='7gFFv'><dir id='7gFFv'><q id='7gFFv'></q></dir></style></legend>

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

        如何添加和刪除“自定義"C# 中的選項卡

        How to add and remove quot;customquot; tabs in C#(如何添加和刪除“自定義C# 中的選項卡)

          <bdo id='LKVCh'></bdo><ul id='LKVCh'></ul>

            • <small id='LKVCh'></small><noframes id='LKVCh'>

            • <tfoot id='LKVCh'></tfoot>
              1. <legend id='LKVCh'><style id='LKVCh'><dir id='LKVCh'><q id='LKVCh'></q></dir></style></legend>
                  <tbody id='LKVCh'></tbody>

                <i id='LKVCh'><tr id='LKVCh'><dt id='LKVCh'><q id='LKVCh'><span id='LKVCh'><b id='LKVCh'><form id='LKVCh'><ins id='LKVCh'></ins><ul id='LKVCh'></ul><sub id='LKVCh'></sub></form><legend id='LKVCh'></legend><bdo id='LKVCh'><pre id='LKVCh'><center id='LKVCh'></center></pre></bdo></b><th id='LKVCh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LKVCh'><tfoot id='LKVCh'></tfoot><dl id='LKVCh'><fieldset id='LKVCh'></fieldset></dl></div>
                • 本文介紹了如何添加和刪除“自定義"C# 中的選項卡的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在制作一個需要添加或刪除選項卡(選項卡控件)的應用程序.我已經很好地完成了標簽的添加和刪除,但是我有自定義按鈕而不是使用標簽.(此按鈕點擊后會跳轉到第一個標簽頁):

                  I am making an application that requires tabs (tab-control) to be added or removed. I have done the add and remove for tabs fine, but I have custom buttons instead of using the tabs. (This button will go the the first tab page when clicked):

                      //This will make it go to TAB 1
                      private void button1_Click(object sender, EventArgs e)
                      {
                          tabControl1.SelectedIndex = 0; 
                      }
                  
                     //This will change the MOUSEENTER to the correct image
                      private void button1_MouseEnter(object sender, EventArgs e)
                      {
                          button1.MouseEnter += new EventHandler(button1_MouseEnter);
                          this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Tab_Down));
                      }
                      //This will change the MOUSELEAVE to the correct image
                      private void button1_MouseLeave(object sender, EventArgs e)
                      {
                          button1.MouseLeave += new EventHandler(button1_MouseLeave);
                          this.button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Tab_Norm));
                      }
                  

                  但是,我將如何創(chuàng)建它,所以當您單擊添加選項卡"按鈕時,它會創(chuàng)建一個新選項卡,但它也會創(chuàng)建一個帶有 tabControl1.SelectedIndex = 1; 的新按鈕,例如.

                  However, how will I create it so when you click the "Add Tab" button it creates a new tab but it also creates a new button with tabControl1.SelectedIndex = 1; in it for example.

                  編輯

                  我這樣做是為了添加一個新選項卡(到 tabControl1):

                  I have done this to add a new tab (to tabControl1):

                   private void button2_Click(object sender, EventArgs e)
                      {
                          string title = "TabPage " + (tabControl1.TabCount + 1).ToString();
                          TabPage myTabPage = new TabPage(title);
                          tabControl1.TabPages.Add(myTabPage);
                      }
                  

                  這會在現(xiàn)有標簽之上添加一個新標簽.但是我該怎么做才能使它還使用上面按鈕的屬性創(chuàng)建一個新按鈕,但它不是 tabControl1.SelectedIndex = 1; 它是 tabControl1.SelectedIndex =3; 每次添加新標簽時都會上升?- 謝謝

                  This adds a new tab on top of the existing ones fine. But I how do I do it so that it also creates a new button with the properties of the button above but makes it so instead of tabControl1.SelectedIndex = 1; it does tabControl1.SelectedIndex = 3; and goes up every time I add a new tab? - Thanks

                  推薦答案

                  經過幾次更新,這里是我的答案的新版本.它告訴你如何

                  After a few updates here is a new version of my answer. It shows you how to

                  • 添加一個 Button,它會添加一個新的 TabPages 并選擇它
                  • 使 Tab 控件在每個選項卡的右側繪制結束x"字符,就像 Firefox 或 Visual Studio 那樣.
                  • Add a Button which adds a new TabPages and selects it
                  • Make the Tab control draw closing 'x' characters to the right of each tab, like Firefox or Visual Studio do it.

                  使添加 Button 像你想要的那樣,也許是 Text="+" 和標簽的高度一樣的高度.它會自動定位在選項卡上.如果您的 Tab 被移動或調整大小,您可能需要重新定位它.

                  Make the add Button like you want it, maybe the Text="+" and the height like the tabs' height. It is automatically positioned on the tab. You may need to reposition it, if your Tab is moved or resized.

                  Form_Load 事件中,Tab 設置為 OwnerDrawFixed 并且每個頁面的文本都附加了幾個空格,以便為關閉騰出空間X.代碼創(chuàng)建一個類變量 closeX 來保存當前的 x 矩形并在 MouseClick 事件中對其進行測試.

                  In the Form_Load event the Tab is set to OwnerDrawFixed and each page's text is append by a few blanks to make room for the closing x. The code creates a class variable closeX to hold the current x-rectangle and tests it in the MouseClick event.

                  確保連接 tabControl1_DrawItemtabControl1_MouseClick 事件!

                  Make sure to wire up the tabControl1_DrawItem and tabControl1_MouseClick events!

                      private void cb_addPage_Click(object sender, EventArgs e)
                      {
                          string title = "TabPage " + (tabControl1.TabCount + 1).ToString() + "   ";
                          TabPage myTabPage = new TabPage(title);
                          tabControl1.TabPages.Add(myTabPage);
                          tabControl1.SelectedTab = myTabPage;
                      }
                  
                  
                      private void Form1_Load(object sender, EventArgs e)
                      {
                          tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;
                          cb_addPage.Top = tabControl1.Top;
                          cb_addPage.Left = tabControl1.Right - cb_addPage.Width;
                          foreach (TabPage tp in tabControl1.TabPages) tp.Text += "   ";
                      }
                  
                  
                      Rectangle closeX = Rectangle.Empty;
                  
                      private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
                      {
                          Size xSize = new Size(13,13);
                          TabPage tp = tabControl3.TabPages[e.Index];
                          e.DrawBackground();
                          using (SolidBrush brush = new SolidBrush(e.ForeColor)  )
                                 e.Graphics.DrawString(tp.Text+ "   ", e.Font,  brush, 
                                                       e.Bounds.X + 3, e.Bounds.Y + 4 );
                  
                          if (e.State == DrawItemState.Selected)
                          {
                             closeX = new Rectangle(
                                 e.Bounds.Right - xSize.Width, e.Bounds.Top, xSize.Width, xSize.Height);
                             using (SolidBrush brush = new SolidBrush(Color.LightGray))
                                  e.Graphics.DrawString("x", e.Font, brush, 
                                                         e.Bounds.Right - xSize.Width, e.Bounds.Y + 4);
                          }
                  
                      }
                  
                      private void tabControl1_MouseClick(object sender, MouseEventArgs e)
                      {
                          if (closeX.Contains(e.Location))
                              tabControl1.TabPages.Remove(tabControl1.SelectedTab);
                      }
                  

                  如果您想使用圖像來裝飾選項卡,請在表單中包含一個 ImageList,使用圖像加載它,如果關閉按鈕是第一個圖像,請像這樣更改代碼:

                  If you want to use an Image to adorn the tabs, include an ImageList with your form, load it with the Image(s) and if the close button is the 1st image, change the code like this:

                      if (e.State == DrawItemState.Selected)
                      {
                          closeX = new Rectangle(e.Bounds.Right - xSize.Width - 3, 
                                                 e.Bounds.Top + 5, xSize.Width, xSize.Height);
                          e.Graphics.DrawImage(imageList1.Images[0], closeX, 
                                               new Rectangle(0,0,16,16), GraphicsUnit.Pixel );
                      }
                  

                  我附上幾頁的 Tab 截圖

                  I append a screenshot of the Tab with a few pages

                  還有一個使用這個 關閉按鈕圖像:

                  And one using this close button image:

                  更新:請注意,如果您的 TabPage 包含 IDisposable 對象,則應確保在刪除頁面之前將它們全部釋放!請參閱此處 例如代碼!

                  Update: Note that if your TabPage contains IDisposable objects you should make sure they all get disposed before you remove the page! See here for example code!

                  這篇關于如何添加和刪除“自定義"C# 中的選項卡的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關文檔推薦

                  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(從函數(shù)調用按鈕 OnClick)
                    <tbody id='YPUUO'></tbody>
                      <bdo id='YPUUO'></bdo><ul id='YPUUO'></ul>
                      <legend id='YPUUO'><style id='YPUUO'><dir id='YPUUO'><q id='YPUUO'></q></dir></style></legend>

                      <tfoot id='YPUUO'></tfoot>

                    • <small id='YPUUO'></small><noframes id='YPUUO'>

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

                          1. 主站蜘蛛池模板: 久久久久一区二区 | 污视频免费在线观看 | 欧美精品在线观看 | 国产一区二区三区四区 | 亚洲一区电影 | 亚洲精品一级 | 国产精品久久久免费 | 久久久国产精品一区 | 在线观看毛片网站 | 精品久久久久香蕉网 | 亚洲视频在线观看免费 | 粉嫩国产精品一区二区在线观看 | 欧美一级大片免费看 | 亚洲精品一区二区在线观看 | 久久精品国内 | 97伦理电影网 | 精品欧美一区二区三区久久久 | 国产美女免费视频 | 免费亚洲婷婷 | 99re在线视频| 中文字幕日韩欧美 | 福利社午夜影院 | 亚洲三区在线播放 | 日韩a视频 | 国产高清在线 | 国产精品揄拍一区二区 | 亚洲国产精品久久 | 成人中文字幕在线 | 亚州精品天堂中文字幕 | 91精品国产综合久久久动漫日韩 | 日韩在线小视频 | 日韩午夜精品 | 一级毛片视频 | 亚洲视频在线观看 | 亚洲+变态+欧美+另类+精品 | 一二区电影 | 免费精品视频在线观看 | 伊人狼人影院 | 国产成人久久精品 | 黄色毛片网站在线观看 | 欧美美乳|