Please enable JavaScript.
Coggle requires JavaScript to display documents.
Winform DataEntryProject, Database Objects in winforms, Currency Manger:
…
Winform DataEntryProject
casting:
private void txtInput_KeyPress(object sender, KeyPressEventArgs e) {
//this is called casting.object sender is a generic object,you know sender is a TexBox class instance, so you can cast it to TextBox
string textBoxSender = ((System.Windows.Forms.TextBox) sender).Name;
}
e.Handled:
private void txtInput_KeyPress(object sender, KeyPressEventArgs e) {
if (textBoxSender == "txtZip") {
if ((e.KeyChar >='0' && e.KeyChar<='9') || e.KeyChar == 8) {
//If the KeyPress event is not handled, it will be sent to the operating system for default processing.
// so when set e.Handled = false;--> this will ask the OS to do the work it should(accept the key press).
//so when set e.Handled = true;--> this will ask the OS not to do the work it should(ignore the key press).
e.Handled = false;
}else {
e.Handled = true;
}
}
a few controls can share the same event handler:
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)----this one is shared by all the txtbox control, when a key is pressed, the event handler is called.
use 'sender' in handlermakes functoin more generic:
private void btnButtons_MouseHover(object sender, EventArgs e) {
((System.Windows.Forms.Button) sender).BackColor = Color.Aqua;
}
InitializeComponent():
all the form controls and events handlers are initialised in here. You can manually add controls or handlers, it is not so hard, but takes a bit time.
-
-
Data binding:
in order to view the data, such as the data we retrieve from Fill(datatable), we need to bind it with some controls in the form.
Binding is usually done on the form load, when we bind each control with its corresponding data.
Complex data binding can be done on:
List Box – display all values of single field (i.e. all book titles)
Combo Box – similar to List Box
Data Grid View – can display the entire table
Simple data binding can be done on:
Label – read only access to data field
Label – read only access to data field
Check Box – read/write Boolean data
Picture Box – read/write access to image/binary field
relational database
intemidiate table:
When two tables are having many to many relationship. It will be confusing. to solve this problem, there should be an intemidiate table siting betwen them, so that the many to many relationship is destructed to 1 to many pluse 1 to one.