Giter Club home page Giter Club logo

tabcontrolwithclosebuttonandaddbutton's Introduction

Tab Control with Close Button and Add Button

You can show close button on tab pages of a tab control to let the users close a tab. Also you can show an add button for tab control to let the users add a new tab.

tabpage close button and add button

To do so, We will use an owner draw tab to show close icons on each tab an add icon on the last tab. We use DrawItem to draw close and add icons, MouseDown to handle click on close and add buttons, Selecting to prevent selecting of the last tab and HandleCreated to adjust tab width.

You need to set a suitable padding and set DrawMode to OwnerDrawFixed and also set the text of last tab page to empty string. We will use that tab as add button.

Handle click on close button and add button

You can handle MouseDown or MouseClick event and check if the last tab rectangle contains the mouse clicked point, then insert a tab before the last tab. Otherwose check if one of close buttons contains clicked location, then close the tab which its close button was clicked

Prevent selectin last tab

To prevent selection the last tab, you can handle Selecting event of control and check if the selecting tab is the last tab, cancel the event.

Draw Close Button and Add Button

To draw close button and add button, you can handle DrawItem event.

Adjust Tab width

Set the last tab text to empty string. Then to adjust tab width and let the last tab have smaller width, you can hanlde HandleCreated event and send a TCM_SETMINTABWIDTH to the control and specify the minimum size allowed for the tab width

Enhancements

You can enhance the implementation by using VisualStyleRenderer and also supporting different tab orientation and also adding rtl support.

tabcontrolwithclosebuttonandaddbutton's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.