Go Back   CodeCall Programming Forum > Software Development > Tutorials > CSharp Tutorials
Register Blogs Search Today's Posts Mark Forums Read

CSharp Tutorials Tutorials for C#

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-2009, 11:35 PM
zeroradius's Avatar
Programming God
 
Join Date: Feb 2008
Location: Ohio
Posts: 785
zeroradius will become famous soon enough
Send a message via AIM to zeroradius Send a message via Yahoo to zeroradius
Basic Data Binding in C#

EDIT: If you would prefer to watch this as a video go to this link: Basic Data Binding In C# | Screencast-O-Matic


Basic Data Binding in C#

Step 1: Create a new windows C# form and name it contactBookV1

basic-data-binding-c-pic1.jpg



Step 2: (Optional) Size your form up a bit by clicking on it in the design window and dragging it up and out

Step3: (Optional) Select the form in the designer and change the text filed in the properties window to “Contact Book V.1” This will change the text at the top of the form

basic-data-binding-c-pic2.jpg


Step4: Create a new Data base by going to Project >> Add New Item

basic-data-binding-c-pic3.jpg



Step4 (Continued): Chose Service-Based Database and name it MyContacts.

basic-data-binding-c-pic4.jpg



Note: Hit the Cancel button on the Data Source Configuration Wizard.


Step5: Right Click on Tables in the Server Explorer Pane (Database Explorer if you are using Express addition) and Select Add New Table from the submenu

basic-data-binding-c-pic5.jpg



Step6: Create your Table by following the below Schema

basic-data-binding-c-schema.jpg


Note: Set Primary key by selecting the desired cell and hitting the key up on the menu

basic-data-binding-c-pic6.jpg



To make it Auto Increment, go to the Column Properties, Under Identity Specification, set (Is Identity) to yes.

basic-data-binding-c-pic7.jpg


(If the c_id filed is not set up correctly your program will crash when you try to use certain features)


Step7: On the menu under file select Save All. Name the database contacts.


Step8: Create a new Database Diagram by right clicking the database diagram in the Server / Database Explorer and selecting new Diagram

basic-data-binding-c-pic8.jpg



The below window will pop up. Select “Yes”

basic-data-binding-c-pic9.jpg


A new table will pop up titled “Add Table” Select Contacts from the list and hit Add

basic-data-binding-c-pic10.jpg


Save the Diagram as contactsDiagram


Step9: Go back to the Form1.cs *design* tab. From the menu bar select Data >> Add New Data Source

basic-data-binding-c-pic11.jpg


Select Database from the new popup window. Proceed to hit the next button until you get to the final page. On the last page check all the check boxes and hit finish.

Step 10: Go to the Data Source Pane and expand the field called Contacts so that you see all the cell names from your database. click on Category and then click on the silver down arrow that appears next to it. Select Combo box from the menu that appears.

basic-data-binding-c-pic12.jpg


Step11: Left Click on each filed in turn and drag it onto the windows form (Do not put c_id on the form) and put them in some type of pattern. You can change the lable to each control the same way we changed the forms text in Step 3 (Note: Make sure you select the lable [Black text] Not the text box [white box])


Your form should now look like this:

basic-data-binding-c-pic13.jpg


Step12: left click the combo box for category on your form. Chose Items from the properties pane and enter in the values Friend, Business, and Other then hit OK button

basic-data-binding-c-pic14.jpg



Step13: Save your work and hit F5, everything should work except saving. You will have to Create a setup to do that.

Step14: Time to create that install so everyone can use your application. Select Build on the menu than select Publish contactBookV1 from the submenu.

basic-data-binding-c-pic15.jpg


Hit finish on the window that pops up to accept all the defaults.

Inside your project folder you will find a folder called Publish. Grab all of its content and copy it to a disk. Go install it on a computer and go crazy ^_^

(Ehh I think I got all the images in the right spot. If every thing wasnt clear I apologise, this is my first tut.)
__________________


Last edited by zeroradius; 08-11-2009 at 02:40 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-11-2009, 08:22 AM
Jordan's Avatar
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 24,556
Jordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to all
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Re: Basic Data Binding in C#

Awesome tutorial! I love the screenshots, looks like you spent some time on them. Nice work. +rep
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-11-2009, 10:42 AM
Parabola's Avatar
Programming Professional
 
Join Date: Jul 2009
Location: Texas
Age: 25
Posts: 299
Parabola will become famous soon enoughParabola will become famous soon enough
Send a message via AIM to Parabola Send a message via MSN to Parabola Send a message via Yahoo to Parabola Send a message via Skype™ to Parabola
Re: Basic Data Binding in C#

..... well.... I was literally about to post a very similar tutorial.. and you beat me to it. Nice work, I'm going to +rep, but unfortunately I don't have much rep power yet

Reason for my program was that I was having to constantly go into SQL and lookup parts to get price and description data, so I wrote a quick app to do that for me. Was also going to include this in the tutorial, which may still be useful to anyone else:

Code:
        private void getData()
        {
            try
            {
                this.inventory_pricingTableAdapter.Fill(this.marksDataSet.inventory_pricing, partNumToolStripTextBox.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        private void partNumToolStripTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                getData();
            }
        }
Everyone should get the idea- If you press enter on a text entry box, it does getData()


Still, Nice work, well done.
__________________
Programmer (n): An organism that can turn caffeine into code.
Programming would be so much easier without all the users.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-11-2009, 11:42 AM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
Re: Basic Data Binding in C#

Nicely done. I love step-by-step stuff (and concept stuff)
__________________
CodeCall Blog | CodeCall Wiki | Shareware
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-11-2009, 01:04 PM
zeroradius's Avatar
Programming God
 
Join Date: Feb 2008
Location: Ohio
Posts: 785
zeroradius will become famous soon enough
Send a message via AIM to zeroradius Send a message via Yahoo to zeroradius
Re: Basic Data Binding in C#

EDIT: I made a video tutorial using better software. See my first post for the link


Thanks guys ^_^ I origonaly did it as a video tutorial but the screencast software I am using (CamStudio) starts to lag after a while so that my naration dosent match with the video so I decided to do it the long way.
__________________


Last edited by zeroradius; 08-11-2009 at 02:41 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
C#:Tutorial - Download Data Xav CSharp Tutorials 12 01-22-2010 04:19 AM
C++ Understanding Basic Data Types WingedPanther C Tutorials 9 01-11-2009 11:08 AM
Choosing the right language / data structure / Interface ups General Programming 1 09-20-2008 10:11 AM


All times are GMT -5. The time now is 10:33 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0