I have a form with data bindings. and i use a BindingManagerBase to travel
through the records
SqlConnection con = Global.Con;
con.Open();
da = new SqlDataAdapter("SELECT * FROM Customer", con);
mcb = new SqlCommandBuilder(da);
da.Fill(ds, "Customer");
txtCustomerFName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_FName"));
txtCustomerLName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_LName"));
txtCustomerAddress.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Address"));
txtCustomerEmail.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Email"));
txtCustomerRegDate.DataBindings.Add(new Binding("Value", ds.Tables["Customer"], "Reg_Date"));
txtCustomerLoyalty.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Loyalty"));
bm = this.BindingContext[ds.Tables["Customer"]];
private void cmdBack_Click(object sender, EventArgs e)
{
if (bm.Position == 0)
MessageBox.Show("Reached beginning of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
bm.Position -= 1;
}
private void cmdNext_Click(object sender, EventArgs e)
{
if (bm.Position == (bm.Count - 1))
MessageBox.Show("Reached end of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
bm.Position += 1;
}
private void CustomerSearch_Load(object sender, EventArgs e)
{
SqlConnection con = Global.Con;
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Customer", con);
da.Fill(ds, "Customer");
dv.Table = ds.Tables[0];
DGV1.DataSource = dv;
}
private void txtSearchString_TextChanged(object sender, EventArgs e)
{
dv.RowFilter = "Cus_FName LIKE '*" + txtSearchString.Text + "*' OR Cus_LName LIKE '*" + txtSearchString.Text+ "*' OR Cus_Address LIKE '*" + txtSearchString.Text + "*' OR Cus_Email LIKE '*" + txtSearchString.Text + "*'";
}
I hope you get the problem. Please ask me if this is not clear. How can i do that?
Ranhiru CoorayPosted May 13, 2009, 8:24 PM