473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Select row on DataGridView and display info in other controls

Hi, i'm new at this forum, and well, as i'm not too familiar with C#, i made a search on populating different controls using a row from a DataGridView, but i couldn't find anything that indeed showed how to do it.
I'm sry for the inconvenience, but i need some help here.

Greetings
Oct 8 '08 #1
1 1226
mldisibio
190 Expert 100+
The clearest set of examples I have seen are given by Brian Noyes in his book "Data Binding With Windows Forms 2.0" published by Addison-Wesley. Here is a sample chapter, but unfortunately it is not the exact chapter you need. It will give you an idea what to look for though:
Presenting Data with the DataGridView

If you want to bind several controls to a DataGridView row, you may need to clarify your objective a bit.

Is there only one row of data you want to bind to? In that case, you would set up some type of BindingSource object that wraps the Row, and use the Control.DataBindings.Add() method to bind a control property (such as 'Text') to a property (column value) of the row.

However, if you want a set of controls to display different values for several different rows, then both the DataGridView and the Controls need to share a common BindingSource object which wraps a collection of class instances, where each instance holds one complete set of data you want to display. (Possibly (all depends on your UI) a BindingNavigator would ease navigation).

Both the controls and the DataGrid would bind to individual properties of each object instance, and the BindingSource wraps a collection of these instances.

So for example, if you have a Customer class with Name, Id and StoreLocation, you would have a collection of Customers (say a List<Customer>, a BindingSource whose DataSource is the List<Customers>, and both the DataGridView and the set of controls will individually bind to that BindingSource.

Note that this allows you to remove or change the DataGridView or individual controls without affecting the underlying binding. In other words, do not try to tightly couple your control binding to the DataGridView. Use a BindingSource to implement a loosely coupled architecture.
Oct 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mark carew | last post by:
Hi, Problem - An extra column to the left (even with row headers disabled) ---------------------------------------------------------- Apologies if this posting is already in the newsgroup; but...
0
by: Nathan | last post by:
Hi, I have a DataGridView that I'm binding to a List<> and then displaying specific properties. Where I have a problem is trying to display the property from an object which in itself is a...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
1
by: --== Alain ==-- | last post by:
Hi, I would like to know why a lot of people wants to work with ListView control when DataGridView control already do the same thing ? for example, in my case i would like to display spin...
3
by: connected | last post by:
I'm having difficulty with populating a DataGridView control with data correctly. It works with a single class, for example... class MyClass { private string _propertyOne; private string...
3
by: Johnny E. Jensen | last post by:
Hello Dot sure if this it the right group but here goes. I'am using the DataGridView multiple times in my application, and then i'll read a book on inherience, and that opend a new world for...
8
by: Brian Pelton | last post by:
This is on .Net 2.0 in a WinForms application. I have a DataGridView that is bound to a BindingSource. The DataGridView has 3 columns. The first two are "normal" text columns and the last is a...
0
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I am a .NET newbie, specifically WinForms. I have a simple Winform for which I have a "How To" question: My WinForm app will display data from a FoxPro database, two tables in particular:...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.