|
The Form design,
About.cs
Create Visual Basic 2010 Forn - About.cs
Classes used in this Form: 1- DataSet,
PictureBox, Label,
TextBox, Button
1- Logical DbConnection &
Logical DbDataAdapter classes,
Create the Form
about.cs
Add New Item -
about.cs Form to App_CAKJV10
Project
- On the Projet
menu , click Add New Item ...,
Add New Item - App_CAKJV10 dialog box appears, Select
Windows form Icon,
in the Name box type
about.cs and then click
Add.
|
 |
|
Note:
In the Windows Forms Designer appears the
design form created and in the Properties
Windows displays the corresponding properties
and
The design Form about.cs created, appears the empty window Form
design |
|
The codes file, created
... |
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
App_CAKJV10
{
public
partial
class
about :
Form
{
public
about()
{
InitializeComponent();
}
private
void about_Load(object
sender,
EventArgs
e)
{
}
}
}
|
|
|
|
|
- The bmp file
diam1.bmp of the folder-c:\App_CAKJV10/App_CAKJV10/Pic
- On the Projet
menu , click Add Existing Item ...,
Add Existing Item - App_CAKJV10dialog box
appears, select the files diam1.bmp of the folder
c:\App_CAKJV10/App_CAKJV10/Pic, and then click
Open.
|
1. |
The
About.cs
design |
|
 |
The Properties of the
Form - About.cs... |
|
Old |
New |
Name: Icon: Maximize: Menu: Size: Start
Position: Text: Window
State: |
About Icon True (none) 400,250 WindowsDefaultLocation About Normal |
About Icon False (none) 368,216 CenterScreen About Normal | | | |
2. |
List
of controls created by the Data Form Wizard
...
1- one DataSet control, one
Label control, one TextBox control and two
Button control
2- One Logical DbConnection
control, one Logical DbDataAdapter
control |
|
- The
DataSet
control, created by
...
Datasets store
data in a disconnected cache. The structure
of a dataset is
similar to that of a relational
database; it exposes a hierarchical object
model of tables, rows, and
columns. In addition, it contains
constraints and relationships defined for the
dataset.
The
objKJV2002dset
Properties:
Name: DataSetName: |
objKJV2002dset KJV2002dset | |
- The TextBox
control, created by
... - EditTextData
Properties:
DataBindings
Text: Name: BackColor: BorderStyle: Font: Locked: Multiline: Size: Text: |
objKJV2002dset
-
BibleTable.TextData EditTextData Window Fixed3D Microsoft
Sons Serief,
8.25pt False False 100,20 | |
- The
Label control, created by
... - lblTextData
Properties:
Name: Text: |
lblTextData TextData | |
- The
Button control, created by
... - btnLoad
Properties:
Name: Size: Text: |
btnLoad 75,23 &Load | |
- The
Button control, created by
... - btnUpdate
Properties:
Name: Size: Text: |
btnUpdate 75,23 &Update | | | |
3. |
a- |
Remove the following controls
created by Wizard: one
Label control -
lbTextData and two Button
controls - btnLoad and
btnUpdate |
b- |
Modify the
Properties of the
TextBox control
-
EditTextData:
DataBindings
Text: Name: BackColor: BorderStyle: Font: Locked: Multiline: Size: |
objKJV2002dset
-
BibleTable.TextData EditTextData Control None Times
New Roman,
9.75pt True True 264,88 | |
Display the 1st record of
the KJV2002.mdb database
Access file |
c-- |
From the Toolbox/Windows Form add
these controls .... One
PictureBox control, two
Label controls
and two Button
controls. | |
|
- Add
the PictureBox
control - PictureBox1,
PictureBox
Properties:
Name: Image: Size
Mode: |
PictureBox1 System.Drawing.Bitmap Autosize | |
Bitmap file
added =
C:\App_CAKJV10/App_CAKJV10/Pic\diam1.bmp
- Add
the Label
control
- Label1, Label
Properties:
Name: Font: Size: Text: TextAlign: |
Label1 Times New Roman,
9.75pt,
style=Bold, Italic 150,16 KJV2002 database
info: TopLeft | |
- Add
the Label
control
- Label2, Label
Properties:
Name: Font: Size: Text: TextAlign: |
Label2 Times New Roman,
9.75pt,
style=Bold, Italic 150,16 developed with
Visual C# 2010 TopLeft | |
- Add
the Label
control
- Line1,
Label Properties:
Name: BackColor: Size: Text: |
Line1 Windows
Text 264,1 | |
- Add
the Button
control - btnbiography,
Button
Properties:
Name: BackColor: Size: Text: |
btnbiograohy Scrollbar 80,24 Created
by | |
- Add
the Button
control - btnDone, Button
Properties:
Name: BackColor: Size: Text: |
btnDone Scrollbar 80,24 Done | | | | |
|
About.cs file, the codes after
modification ...
|
|
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using
System.Drawing;
using System.Linq;
using System.Text;
using
System.Windows.Forms;
using
System.Data.OleDb;
namespace
App_CAKJV10
{
public
partial
class
About
:
Form
{
// Declaration, MainForm Form
App_CAKJV10. MainForm
fm =
new
MainForm();
//connection
System.Data.OleDb. OleDbConnection
bConnection =
new
System.Data.OleDb.OleDbConnection();
// Select command
System.Data.OleDb. OleDbCommand
selectCMD;
// Data adapter
System.Data.OleDb. OleDbDataAdapter
bookDA =
new
System.Data.OleDb.OleDbDataAdapter();
public About()
{
InitializeComponent();
}
private
void
About_Load(object
sender,
EventArgs
e)
{
this.bConnection.ConnectionString
=
@"Provider=""Microsoft.Jet.OLEDB.4.0"";Data
Source=""C:\App_CAKJV10\App_CAKJV10\pic\KJV2002.mdb"";Persist
Security Info=False;User ID=Admin;Mode=Share Deny None;Jet
OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet
OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:Create System Database=False;Jet
OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale
on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False";
try
{
// Attempt to load the dataset.
this.LoadDataSet();
}
catch (System.Exception
eLoad)
{
// Add your error handling code here.
// Display error message, if any.
System.Windows.Forms. MessageBox.Show(eLoad.Message);
}
// StatusBar Panel N1 = Message
// fm.Show();
// fm.statusBarPanel1.Text = "Ready...";
// fm.Refresh();
}
public
void
LoadDataSet()
{
// Create a new dataset to hold the records returned from
the call to FillDataSet.
// A temporary dataset is used because filling the
existing dataset would
// require the databindings to be rebound.
App_CAKJV10. Aboutdset
objDataSetTemp;
objDataSetTemp =
new
App_CAKJV10.Aboutdset();
try
{
// Attempt to fill the temporary dataset.
this.FillDataSet(objDataSetTemp);
}
catch (System.Exception
eFillDataSet)
{
// Add your error handling code here.
throw eFillDataSet;
}
try
{
// Empty the old records from the dataset.
aboutdset1.Clear();
// Merge the records into the main dataset.
aboutdset1.Merge(objDataSetTemp);
}
catch (System.Exception
eLoadMerge)
{
// Add your error handling code here.
throw eLoadMerge;
}
}
public
void
FillDataSet(App_CAKJV10.Aboutdset
dataSet)
{
// Turn off constraint checking before the dataset is
filled.
// This allows the adapters to fill the dataset without
concern
// for dependencies between the tables.
dataSet.EnforceConstraints =
false;
try
{
selectCMD =
new
System.Data.OleDb.OleDbCommand("SELECT
Book, BookTitle, Chapter, Verse, TextData FROM BibleTable
ORDER BY Book, Chapter, Verse",
this.bConnection);
selectCMD.Connection =
this.bConnection;
bookDA.SelectCommand = selectCMD;
// Open the connection.
this.bConnection.Open();
// Attempt to fill the dataset through the bookDA.
this.bookDA.Fill(dataSet,
"BibleTable");
}
catch (System.Exception
fillException)
{
// Add your error handling code here.
throw fillException;
}
finally
{
// Turn constraint checking back on.
dataSet.EnforceConstraints =
true;
// Close the connection whether or not the exception was
thrown.
this.bConnection.Close();
}
}
private
void
btnDone_Click(object
sender,
EventArgs
e)
{
this.Close();
fm.Show();
fm.statusBarPanel1.Text =
"Hello ...";
fm.Refresh();
}
}
}
| | |
|
|