Let us choose the Details
view option and then drag-and-drop the fields we need to place on the form.
We do have display options for each field as shown in the following screenshot.
Before placing the field onto the form, we can choose the control type.
On placing the fields on the surface, we can also see a navigation bar and the editing
controls getting added to the form. This automatic placement of editing controls
reduces our design time for designing the form.
LINQ to SQL
[ 132 ]
We have created the data source object and placed all the controls on the form. Now
we need to get the data from the database through the data source and bind it to
the controls. The important thing required for this is the connection to the database.
We know that we have the connection DataContext which has the connection
information. Add the following code to the form:
public partial class Form1 : Form
{
private DataClasses1DataContext connection = new
DataClasses1DataContext();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
categoryBindingSource.
Pages:
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214