winforms - Resizing button size during run-time in C# with mouse -


i using following code make , move buttons @ runtime mouse.

i want resize them mouse. code provided kekusemau. lot kekusemau this; helped me.

private point origin_cursor; private point origin_control; private bool btndragging = false;    private void button1_click(object sender, eventargs e) {     var b = new button();     b.text = "my button";     b.name = "button";     //b.click += new eventhandler(b_click);     b.mouseup += (s, e2) => { this.btndragging = false; };     b.mousedown += new mouseeventhandler(this.b_mousedown);     b.mousemove += new mouseeventhandler(this.b_mousemove);     this.panel1.controls.add(b); }  private void b_mousedown(object sender, mouseeventargs e) {     button ct = sender button;     ct.capture = true;     this.origin_cursor = system.windows.forms.cursor.position;     this.origin_control = ct.location;     this.btndragging = true; }  private void b_mousemove(object sender, mouseeventargs e) {     if(this.btndragging)     {         button ct = sender button;         ct.left = this.origin_control.x - (this.origin_cursor.x - cursor.position.x);         ct.top = this.origin_control.y - (this.origin_cursor.y - cursor.position.y);     } } 

i having problem change between move , resize option . want when mouse pointer on edges of button , should resize , when in center of button should move button mouse pointer .

controls (like button) in winforms have size (width, height) , location (x, y), units pixels.

modifying properties relatively straightforward: shows example clicking on button make 10 px wider , 10 px higher, , move 10 px right , 10 px down.

  private void button1_click(object sender, eventargs e)         {             button button = (button)sender;              button.width = button.width + 10;             button.height = button.height + 10;              button.location = new point(button.location.x + 10, button.location.y + 10);          } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -