Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp6
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. this.MouseClick += Form1_MouseClick;
  19. }
  20.  
  21. private void Form1_MouseClick(object sender, MouseEventArgs e)
  22. {
  23. Control element;
  24.  
  25. if (e.Location.X < (Size.Width / 2))
  26. {
  27. element = new Button() { Text = "Кнопка" };
  28. element.Size = new Size(75, 23);
  29. }
  30. else
  31. {
  32. element = new TextBox() { Text = "Поле ввода" };
  33. element.Size = new Size(123, 20);
  34. }
  35.  
  36. element.Location = e.Location;
  37. this.Controls.Add(element);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement