fork download
  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 WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private Label lbl = null;
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. lbl = new Label();
  24. lbl.Text = "入力してください。";
  25. lbl.Cursor = Cursors.IBeam;
  26. lbl.Click += lbl_Click;
  27. lbl.Anchor = AnchorStyles.Right;
  28. lbl.AutoSize = true;
  29. lbl.BackColor = Color.Transparent;
  30. lbl.ForeColor = Color.Gray;
  31. textBox1.Enter += lbl_Click;
  32. textBox1.Leave += textBox1_Leave;
  33. textBox1.Controls.Add(lbl);
  34. }
  35.  
  36. void textBox1_Leave(object sender, EventArgs e)
  37. {
  38. if (string.IsNullOrEmpty(textBox1.Text))
  39. {
  40. lbl.Visible = true;
  41. }
  42. }
  43.  
  44.  
  45. void lbl_Click(object sender, EventArgs e)
  46. {
  47. this.lbl.Visible = false;
  48. this.textBox1.Focus();
  49. }
  50. }
  51. }
  52.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty