I want to create a custom button control like this (the image button is fine).
I 'am a new user, so I can not post image here. So I uploaded the photo
I am still desperate after trying some tutorials
Any suggestion is highly appreciated.
Thank you
You can create a class that lets all your styles Receives from the button to place it in place. You can change the button or change button events to do hover and pressed states.
An example of one of our projects is here (I changed the color but your idea has been received). Where we change some colors, you can switch images.
Public class Mossy button: Button {Personal static font _normalFont = new font ("Aile", 10F, System.Downing.FontStyle.bold, System.Dragging.Graphic Unit.Point, ( Byte) (0))); Private Static Color _back = System Drawing Collar Gray; Private Static Color _border = System.Drawing.Color.Black; Private Static Color _activeBorder = System.Drawing.Color.Red; Private static color _fore = System.Drawing.Color.White; Private static padding _ margin = new system.windows.form. Padding (5, 0, 5, 0); Private steady padding _pading = new system.windo.form. Padding (3, 3, 3, 3); Private static size _minSize = new system Drawing Size (100, 30); Private Bull _ Active; Public Mosibuton (): Base () {base.font = _normalFont; base. Back collar = _border; Base.ForeColor = _fore; Base.FlatAppearance.BorderColor = _back; Base.FlatStyle = System.Windows.Forms.FlatStyle.Flat; Base. Margin = _ margin; Base.Padding = _padding; Base.MinimumSize = _minSize; } Safe Override Zero On-ControlWall (ControlEventErgus E) {base.OnControlAdded (e); UseVisualStyleBackColor = false; } Secure Override Zero OnMouseEnter (System.EventArgs e) {base.OnMouseEnter (e); If (! _active) base.FlatAppearance.BorderColor = _activeBorder; } Secure Override Zero OnMouseLeave (System.EventArgs e) {base.OnMouseLeave (e); If (! _active) base.FlatAppearance.BorderColor = _border; } Public Zero SetStateActive () {_active = true; Base.FlatAppearance.BorderColor = _activeBorder; } Public Zero SetStateNormal () {_active = false; Base.FlatAppearance.BorderColor = _border; }}
Comments
Post a Comment