As we've already seen, you can use data grids to display entire data tables, as in the DataBinding example on the CD-ROM, as discussed in the In Depth section of this chapter. To bind a data grid to a table, you can set the data grid's DataSource property (usually to a dataset, such as dsDataSet) and DataMember property (usually to text naming a table like "authors"). At run time, you can set both of these properties at once with the built-in data grid method SetDataBinding (data grids are the only controls that have this method):
You can use these data sources with the data grid's DataSource property:
single dimension arrays
To determine which cell was selected by the user, use the CurrentCell property. You can change the value of any cell using the Item property, which can take either the row or column indexes of the cell. And you can use the CurrentCell Changed event to determine when the user selects another cell.
You can see an example of data binding with this control in the DataBinding example on the CD-ROM in Figure 21.3, where I've bound the data grid to the authors table in the pubs database.