Hi NazHim,
Do you want to get a specific value from the BindingSource and not from the DataGridView control?
If so, you can use BindingSource.Current property to to access the current item.
Here is a code example:
public BindingSource bindingSource1 = new BindingSource();
private void Form1_Load(object sender, EventArgs e)
{
PopulateBindingSourceWithFonts();
}
private void PopulateBindingSourceWithFonts()
{
bindingSource1.CurrentChanged += new EventHandler(bindingSource1_CurrentChanged);
bindingSource1.Add(new Font(FontFamily.Families[2], 8.0F));
bindingSource1.Add(new Font(FontFamily.Families[4], 9.0F));
bindingSource1.Add(new Font(FontFamily.Families[6], 10.0F));
bindingSource1.Add(new Font(FontFamily.Families[8], 11.0F));
bindingSource1.Add(new Font(FontFamily.Families[10], 12.0F));
DataGridView view1 = new DataGridView();
view1.DataSource = bindingSource1;
view1.AutoGenerateColumns = true;
view1.Dock = DockStyle.Top;
this.Controls.Add(view1);
}
void bindingSource1_CurrentChanged(object sender, EventArgs e)
{
MessageBox.Show(bindingSource1.Current.ToString());
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.