Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,025

HOME > .NET Framework > DataGridView , ComboBox , ListBox : Basic in (.NET) Windows Forms Application




Clound SSD Virtual Server

DataGridView , ComboBox , ListBox : Basic in (.NET) Windows Forms Application

 
  DataGridView , ComboBox , ListBox : Basic in (.NET) Windows Forms Application บทความ Basic .NET พื้นฐานการสร้าง Data Source และ BindData ให้กับ Control บน Windows Forms ด้วย Wizard ของ Visual Studio

จากบทความ

.NET Windows Forms Application เขียนโปรแกรมบน Windows Forms Application ด้วย .NET Framework


บทความนี้จะเป็นภาคต่อจากบทความที่แล้ว เป็นตัวอย่างการใช้ Wizard ของ Visual Studio 2010 ในการสร้าง DataGridView , ComboBox , ListBox และสร้าง Data Source ด้วย Wizard และทำการ BindData ให้กับ Control

สำหรับบทความนี้จะเน้นการใช้ Wizard หรือสำหรับผู้ที่ต้องการสร้าง Data Source ด้วยตนเอง และทำการ BindData ผ่านการเขียน Code สามารถดูตัวอย่างได้จากบทความของ .NET ในส่วนของ ASP.NET กับ DataBinding



จะมีตัวอย่างทั้ง Code ภาษา VB.NET และ C# ปกติแล้วการเขียนโปรแกรมบน .NET ในรูปแบบของ Web Application (ASP.NET) หรือ Windows Forms Application นั้นรูปแบบการสร้าง Data Source สามารถใช้ได้เหมือนกันทุกประการ แต่ในการ BindData ให้กับ Control บน Web App กับ Windows App นั้นอาจจะต่างกัน แต่สามารถประยุกต์ใช้งานได้อย่างไม่ยากเลย


Windows Forms Application Control

Control บน Visual Studio 2010 (Windows Forms Application) สำหรับการใช้งาน Control แต่ล่ะตัว ถ้ามีโอกาศผมจะได้ทยอยทำการ Review Control ที่มีการใช้งานบ่อย ๆ ซึ่งถ้าหากจะหัดลองใช้ดูแล้วจะรู้ว่า Control พวกนี้สามารถใช้งานได้อย่างง่ายดาย

เริ่มต้นจากการ New Project ขึ้นมาใหม่ (ตัวนี้เขียนบน Visual Studio 2010)

DataGridView , ComboBox , ListBox

Menu File -> New Project

DataGridView , ComboBox , ListBox

เลือกพัฒนา Windows Forms Application ส่วนภาษานั้นสามารถเลือกใช้ได้ตามถนัด ว่าจะเป็น VB.NET หรือ C#

DataGridView , ComboBox , ListBox

ทดสอบการสร้างโฟเดอร์สำหรับเก็บ Database ในตัวอย่างนี้จะใช้ Database Access (mdb)








DataGridView , ComboBox , ListBox

Copy Database มาวางเรียบร้อย โดย Database นี้อาจจะใช้การสร้างบนโปรแกรม Microsoft Access (mdb)


ตัวอย่างการสร้าง DataGridView

DataGridView , ComboBox , ListBox

คลิกที่ Control DataGridView และลากไปยังส่วนของ Forms

DataGridView , ComboBox , ListBox

คลิกที่ Icon เล็ก ๆ ดังรูปเพื่อเรียกใช้ Task Wizard

DataGridView , ComboBox , ListBox

ในส่วนของ Choose Data Source ในกรณีที่มี Data Source อยู่แล้วสามารถทำการเลือกได้ในทันที หรือจะสร้าง Data Source ใหม่โดยไปที่ Add Project Data Source


การสร้าง Data Soruce

DataGridView , ComboBox , ListBox

เลือกรูปแบบของ Data Source ในที่นี้จะเลือก Database

DataGridView , ComboBox , ListBox

เลือกเป็น DataSet และกด Next เพื่อไปขั้นตอนถัดไป

DataGridView , ComboBox , ListBox

ในกรณีที่ใน Project มี Connection ที่ถูกสร้างไว้แล้วสามารถเลือกได้จาก DropDownList ได้ในทันที หรือถ้าหากไม่มีให้เลือก New Connection

DataGridView , ComboBox , ListBox

เลือกประเภทของ Data Source ในตัวอย่างนี้ให้เลือกเป็น Microsoft Access และเลือก Browse เพื่อเลือก Path ทีเก็บไฟล์ของ Access

DataGridView , ComboBox , ListBox

เลือกเรียบร้อย ในที่นี้ได้เก็บไว้ที่โฟเดอร์ชื่อ database

DataGridView , ComboBox , ListBox

กด OK เพื่อไปยังขั้นตอนถัดไป

DataGridView , ComboBox , ListBox

สังเกตุว่า Connection String ได้ถูกสร้างไว้แล้ว ในกรณีที่สร้าง Data Source อื่น ๆ ก็สามารถเรียก Connection String นี้ใช้งานได้อีกโดยไม่ต้องสร้างขึ้นมาใหม่

DataGridView , ComboBox , ListBox

กำหนดชื่อ Connection String และเลือก Next เพื่อไปยังขั้นตอนถัดไป

DataGridView , ComboBox , ListBox

เลือก Table หรือชื่อตาราง และ Finish

DataGridView , ComboBox , ListBox

กลับมายัง Forms ของ DataGridView ทีไได้สร้างไว้ ซึ่งในตอนนี้มี Data Source เป็นที่เรียบร้อยแล้ว

DataGridView , ComboBox , ListBox

หากไม่ต้องการกำหนดคุณสมบัติอื่น ๆ สามารถทำการรันโปรแกรมได้ทันที

DataGridView , ComboBox , ListBox

แสดงผลเรียบร้อย

DataGridView , ComboBox , ListBox

ในกรณีที่ต้องการปรับแต่ง DataGridView ก็สามารถทำได้ง่าย ๆ โดยคลิกที่ Edit Columns

DataGridView , ComboBox , ListBox

กำหนดคุณสมบัติของ DataGridView ซึ่งถ้ามีโอกาสจะได้ ทำบทความเกี่ยวกับการใช้งาน DataGridView ในรูปแบบอื่น ๆ








ตัวอย่างการสร้าง Combobox

DataGridView , ComboBox , ListBox

สร้าง Control ComboBox

DataGridView , ComboBox , ListBox

กำหนด Data Source ที่ได้จากขั้นตอนก่อนหน้านี้

DataGridView , ComboBox , ListBox

ทดสอบการรันโปรแกรม


ตัวอย่างการสร้าง ListBox

DataGridView , ComboBox , ListBox

สร้าง Control ListBox

DataGridView , ComboBox , ListBox

กำหนด Data Source ที่ได้จากขั้นตอนก่อนหน้านี้

DataGridView , ComboBox , ListBox

ทดสอบการรันโปรแกรม

บทความอื่น ๆ ที่เกี่ยวข้อง
- การสร้างฟอร์มด้วย DataGridView เบื้องต้นแบบ Step by Step VB.NET (Windows App+SQL Server)
- ASP.NET Web Control & DataBinding
- .NET Windows Forms Application เขียนโปรแกรมบน Windows Forms Application ด้วย .NET Framework


       
Bookmark.   
       

 

  By : TC Admin
  Score Rating : -
  Create Date : 2011-07-09 12:11:10
  Download : No files
     

Clound SSD Virtual Server
-->
Related Links
Install .NET Framework 2.0 & Visual Studio 2005
Install .NET Framework 2.0 & Visual Studio 2005
Install .NET Framework 2.0 & Visual Studio 2005 ติดตั้งและใช้งาน .NET Framework 2.0 และ VS 2005
Rating :
Update :
2009-01-11 09:44:53 View : 8,867
.NET Parameterized Queries
.NET Parameterized Queries
.NET Parameterized Queries
Rating :
Update :
2017-03-24 21:20:12 View : 10,714
การสร้าง Crystal Report กับการสร้าง Class และ DataSource (.NET)
การสร้าง Crystal Report กับการสร้าง Class และ DataSource (.NET)
ตัวอย่างการสร้าง class บน .net framework เพื่อสร้าง dataset และ datatable กำหนดค่า datasource ให้กับ crystal report
Rating :
Update :
2017-03-24 21:32:24 View : 21,782
VB.NET/C# Connect to SQL Server Using ADO.NET พื้นฐานกับ SQL Server and ADO.NET
VB.NET/C# Connect to SQL Server Using ADO.NET พื้นฐานกับ SQL Server and ADO.NET
SQL Server เชื่อมติดต่อผ่าน ADO.NET เพื่อเขียนโปรแกรมด้วยภาษา VB.NET และ C#
Rating :
Update :
2017-03-24 21:30:04 View : 62,236
การสร้าง Report ด้วย Report Viewer และการส่งค่า Parameters (ReportViewer , MicrosoftReportViewer)
การสร้าง Report ด้วย Report Viewer และการส่งค่า Parameters (ReportViewer , MicrosoftReportViewer)
ออกรายงานด้วย report viewer ซึ่งเป็น report ของค่าย microsoft ที่สามารถใช้งานได้ฟรี มีมาพร้อมกับ visual studio 2005 (.net 2.0) ขึ้นไป
Rating :
Update :
2017-03-24 21:33:46 View : 90,012
สร้าง Parameter และ Formula Fields บน Crystal Reports (VB.NET,C#)
สร้าง Parameter และ Formula Fields บน Crystal Reports (VB.NET,C#)
บทความ Crystal Report และตัวอย่างการสร้าง Parameters และการส่ง Parameters และการเขียน Formula รับค่าบน Crystal Report
Rating :
Update :
2017-03-24 21:29:30 View : 82,515
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่

Inline