Advertisement
DrAungWinHtut

ListBox

Apr 8th, 2022
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 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 NewTools2
  12. {
  13.     public partial class frmList : Form
  14.     {
  15.         public frmList()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnAddFriend_Click(object sender, EventArgs e)
  21.         {
  22.             funAddRriend();
  23.         }
  24.  
  25.         public void funAddRriend()
  26.         {
  27.             string sFriendName = txtFriendName.Text;
  28.             lbFriendList.Items.Add(sFriendName);
  29.             txtFriendName .SelectAll ();
  30.             txtFriendName .Focus ();
  31.         }
  32.  
  33.         private void txtFriendName_KeyDown(object sender, KeyEventArgs e)
  34.         {
  35.             if(e.KeyCode == Keys.Enter)
  36.             {
  37.                 funAddRriend();
  38.             }
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement