Windows Forms: How to use BindingSource and BindingNavigator in C#
By FoxLearn 7/23/2017 10:05:11 PM 7.16K
How to use bindingsource, bindingnavigator c#
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "BindingSourceDemo" and then click OK
Step 2: Design your form as below
You need to create a user class
public class Users { public string Username { get; set; } public string Password { get; set; } }
Add a bindingsource, bindingnavigator to your windows form application as below
Step 3: Add code to handle your form as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BindingSourceDemo { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //Add user to binding source usersBindingSource.Add(new Users() { Username = "admin", Password = "admin" }); usersBindingSource.Add(new Users() { Username = "user", Password = "123" }); usersBindingSource.Add(new Users() { Username = "sa", Password = "admin" }); usersBindingSource.Add(new Users() { Username = "lucy", Password = "123@qaz" }); } } }
VIDEO TUTORIALS
- Windows Forms: Youtube Search with Paging in C#
- Windows Forms: Text to speech in C#
- Windows Forms: Print Picture Box in C#
- Windows Forms: Advanced Filter DataGridView in C#
- Windows Forms: Progress Bar in C#
- How to create a Lucky Draw games in C#
- Windows Forms: How to Create a Random Password Generator in C#
- Windows Forms: Tag Control in C#
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024
What Are RESTful Web Services?
02/19/2024