Example : Add a new form in project and design it as following.
Output :
Coding:
Output :
Coding:
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 LinqProject1 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } CS11DBDataContext dc; Listcust; int rno = 0; private void Form2_Load(object sender, EventArgs e) { dc = new CS11DBDataContext(); cust = dc.GetTable ().ToList(); ShowData(); } private void ShowData() { txtCustID.Text = cust[rno].CustId.ToString(); txtCname.Text = cust[rno].Cname.ToString(); txtCity.Text = cust[rno].City.ToString(); txtBalance.Text = cust[rno].Balance.ToString(); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void btnNext_Click(object sender, EventArgs e) { if (rno 0) { rno -= 1; ShowData(); } else { MessageBox.Show("First record of the table", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
No comments:
Post a Comment