Hello All,
I have looked all over the internet and have not found a solution to the problem I am having.
Basically I have a datasource bound to some textboxes in a usercontroller. I am trying to set the datasource filter in the usercontrol. I am trying to trigger this from the main form by calling a public method in the user control. When I call the method from the main form, the method runs but nothing happens after the filter has been set. When I set the filter from a button in the usercontrol everything works fine. I have tried using documentsBindingSource.ResetBindings(false); but that doesn't help either. I am not sure what I am doing wrong. Can someone help?
Thanks in advance.
namespace qDoc.Controls
{
public partial class FileDetails : UserControl
{
public FileDetails()
{
InitializeComponent();
documentsTableAdapter.Fill(dsDocumentDetails.Documents);
}
public void LoadDocument()
{
documentsBindingSource.Filter = "DocID=303"; // This is called from parent form. Nothing happens after it's called.
}
private void btnTest_Click(object sender, EventArgs e)
{
documentsBindingSource.Filter = "DocID=303"; // This works and textboxes are updated.
}
}
}namespace qDoc
{
public partial class Form1 : Form
{
...
private void dgFileList_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int col = dgFileList.CurrentCell.ColumnIndex;
int row = dgFileList.CurrentCell.RowIndex;
switch(col)
{
case 0:
MessageBox.Show("Edit DocID : " + dgFileList.Rows[row].Cells[2].Value.ToString());
break;
case 1:
FileDetails fd = new FileDetails();
fd.LoadDocument(); // Calling method in UserControl.
break;
default:
break;
}
}
}
}