Hi...
I am working on desktop application.
I want to search multiple records in AxMSFlexGridLib but following error is happening..
Cross-thread operation not valid: Control 'dateTimePicker1' accessed from a thread other than the thread it was created on.
below is code.
public void SearchCode_Method()
{
this.flex1.set_ColWidth(0, 0x177);
this.flex1.set_ColWidth(1, 0x3e8);
this.flex1.set_ColWidth(2, 0x9c4);
this.flex1.set_ColWidth(3, 800);
this.flex1.set_ColWidth(4, 600);
this.flex1.set_ColWidth(5, 0x44c);
this.flex1.set_ColWidth(6, 0x44c);
this.flex1.set_ColWidth(7, 0x3e8);
this.flex1.set_TextMatrix(0, 0, "S#");
this.flex1.set_TextMatrix(0, 1, "CCode");
this.flex1.set_TextMatrix(0, 2, "Name");
this.flex1.set_TextMatrix(0, 3, "Invoice#");
this.flex1.set_TextMatrix(0, 4, "Qty");
this.flex1.set_TextMatrix(0, 5, "Bkg Date");
this.flex1.set_TextMatrix(0, 6, "Dlv Date");
this.flex1.set_TextMatrix(0, 7, "Amount");
this.flex1.set_ColAlignment(1, 5);
this.flex1.set_ColAlignment(3, 5);
this.flex1.set_ColAlignment(4, 5);
this.flex1.set_ColAlignment(5, 5);
this.flex1.set_ColAlignment(6, 5);
this.flex1.set_ColAlignment(7, 5);
this.colno = 3;
if (this.deliverd)
{
this.table = this.dsdata.Tables[6];
}
else if (this.nondelivered)
{
this.table = this.dsdata.Tables[7];
}
else
{
this.table = this.dsdata.Tables[3];
}
int num2 = 1;
int num3 = 1;
foreach (DataRow row in this.table.Rows)
{
if (num3 >= this.flex1.Rows)
{
this.flex1.Rows++;
this.flex1.set_ColWidth(7, 750);
}
this.flex1.set_TextMatrix(num2, 1, Convert.ToString(row["CCode"]));
this.flex1.set_TextMatrix(num2, 2, Convert.ToString(row["Name"]));
this.flex1.set_TextMatrix(num2, 3, Convert.ToString(row["InvoiceNo"]));
this.dateTimePicker1.Text = Convert.ToString(row["BookingDate"]);
this.flex1.set_TextMatrix(num2, 5, this.dateTimePicker1.Value.ToShortDateString());
this.dateTimePicker1.Text = Convert.ToString(row["DeliveryDate"]);
this.flex1.set_TextMatrix(num2, 6, this.dateTimePicker1.Value.ToShortDateString());
foreach (DataRow row2 in this.dsdata.Tables[0].Rows)
{
if (row["Invoiceno"].ToString() == row2["InvoiceNo"].ToString())
{
this.flex1.set_TextMatrix(num2, 4, Convert.ToString(row2["Quantity"]));
this.flex1.set_TextMatrix(num2, 7, Convert.ToString(row2["Amount"]));
}
}
num3++;
num2++;
}
for (int i = 1; i < num3; i++)
{
this.flex1.set_TextMatrix(i, 0, Convert.ToString(i));
}
this.searchDataset(this.table, this.dsdata.Tables[0], "CCode");
this.btnPrint.Enabled = true;
this.lblnote.Text = "";
}
in above code where exception is happening I did that bold..
any body help me..