Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. int Naslov_rnd;
  2. TextBox tb;
  3.  
  4. private void Naslov_p_Click(object sender, EventArgs e)
  5. {
  6. Naslov_rnd++;
  7.  
  8. tb = new TextBox();
  9. VizitKartica.SuspendLayout();
  10.  
  11. tb.Location = new Point(0, 0);
  12. tb.Multiline = true;
  13. tb.Size = new Size(200, 20);
  14. tb.BorderStyle = BorderStyle.None;
  15. tb.BackColor = Color.DodgerBlue;
  16. tb.ForeColor = Color.White;
  17. tb.Name = "Naslov_" + Naslov_rnd.ToString(); ;
  18. tb.Text = "Dodajte Vaš naslov";
  19. tb.Font = new Font("Microsoft Sans Serif", 12);
  20.  
  21. VizitKartica.Controls.Add(tb);
  22. elementi_lista.AddItem(tb.Name);
  23.  
  24. VizitKartica.ResumeLayout(true); Controls collection
  25.  
  26. tb.MouseMove += new MouseEventHandler(tb_MouseMove);
  27. tb.MouseDown += new MouseEventHandler(tb_MouseDown);
  28. }
  29.  
  30. protected void tb_MouseMove(object sender, MouseEventArgs e)
  31. {
  32. if (e.Button == MouseButtons.Left)
  33. {
  34. tb.Left = e.X + tb.Left;
  35. tb.Top = e.Y + tb.Top;
  36. }
  37. }
  38.  
  39. protected void tb_MouseDown(object sender, MouseEventArgs e)
  40. {
  41. if (e.Button == MouseButtons.Left)
  42. {
  43. Point MouseDownLocation = e.Location;
  44. }
  45. }
  46.  
  47. public partial class Form1 : Form
  48. {
  49. public Form1()
  50. {
  51. InitializeComponent();
  52. }
  53.  
  54. int Naslov_rnd;
  55.  
  56. private void button1_Click(object sender, EventArgs e)
  57. {
  58. Naslov_rnd++;
  59.  
  60. TextBox tb = new TextBox();
  61. VizitKartica.SuspendLayout();
  62.  
  63. tb.Location = new Point(0, 0);
  64. tb.Multiline = true;
  65. tb.Size = new Size(200, 20);
  66. tb.BorderStyle = BorderStyle.None;
  67. tb.BackColor = Color.DodgerBlue;
  68. tb.ForeColor = Color.White;
  69. tb.Name = "Naslov_" + Naslov_rnd.ToString();
  70. tb.Text = "Dodajte Vaš naslov";
  71. tb.Font = new Font("Microsoft Sans Serif", 12);
  72.  
  73. VizitKartica.Controls.Add(tb);
  74.  
  75. VizitKartica.ResumeLayout(true);
  76.  
  77. tb.MouseMove += new MouseEventHandler(tb_MouseMove);
  78. tb.MouseDown += new MouseEventHandler(tb_MouseDown);
  79. }
  80.  
  81. protected void tb_MouseMove(object sender, MouseEventArgs e)
  82. {
  83. TextBox tb2 = (TextBox) sender;
  84. if (e.Button == MouseButtons.Left)
  85. {
  86. tb2.Left = e.X + tb2.Left;
  87. tb2.Top = e.Y + tb2.Top;
  88. }
  89. }
  90.  
  91. protected void tb_MouseDown(object sender, MouseEventArgs e)
  92. {
  93. if (e.Button == MouseButtons.Left)
  94. {
  95. Point MouseDownLocation = e.Location;
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement