Hi,
I am using win-forms applications & c#. I wish to read the text from datagridview1-column1, and I wish to filter the table rows according to the related column1- text values & need to display it in datagridview2.
Currently Iam using it from DataGridView to Listview. But because of Image columns I am in need to display it from datagridview1 to datagridview2. Any kind help will be more useful. Thanks!
The above codes while I press any key simply moving to next cell with datagrid1 and not continue to read the text in same cell until pressing <Enter> Key. Thanks for the helps!
I am using win-forms applications & c#. I wish to read the text from datagridview1-column1, and I wish to filter the table rows according to the related column1- text values & need to display it in datagridview2.
Currently Iam using it from DataGridView to Listview. But because of Image columns I am in need to display it from datagridview1 to datagridview2. Any kind help will be more useful. Thanks!
C#:
private void MyDataGrid1_EditingControlShowing(System.Object Sender, DataGridViewEditingControlShowingEventArgs e) {
MyDGVCurRow = myDataGrid1.CurrentCell.RowIndex;
if ((TextBox) (e.Control)) {
((TextBox)(e.Control)).CharacterCasing = CharacterCasing.Upper;
}
e.Control.TextChanged -= new EventHandler(this.Form_Test.MyDGVColumn_LstVew);
if (myDataGrid1.CurrentCell.ColumnIndex == 1) {
myDataGrid1.CurrentCell = myDataGrid1[1, MyDGVCurRow];
e.Control.TextChanged += new EventHandler(this.Form_Test.MyDGVColumn_LstVew);
}
}
private void MyDGVColumn_LstVew(System.Object Sender, EventArgs e) {
if (myDataGrid1.CurrentCell.ColumnIndex == 1) {
TextBox thisBox =(TextBox)(Sender);
//Data Collection
MyItemCollect();
MyDGVDataSource = MyDataTabl1;
//DataView MyItemFiltView = MyDataTable1.DefaultView;
//MyItemFiltView.RowFilter = null;
//MyItemFiltView.RowFilter = "item_type='" + thisBox.Text + "'";
//DataTable MyDataTable2 = MyItemFiltView.ToTable(); ??????????? Images Disappearing while using filter
//for (int N1 = 0; N1 <= MyDataTbl.Rows.Count - 1; N1++) {
//ChkItm = String.Empty;
//ChkItm = MyDataTbl.Rows[N1]["item_type"].ToString().Trim().ToUpper();
//Naomi = ChkItm.StartsWith(thisBox.Text);
//if (Naomi == true) {
//DataRow MyDRw = MyDGVItemDtb.NewRow();
//MyDRw["item_type"] = MyDataTbl.Rows[N1]["item_type"].ToString();
//MyDRw["item_description"] = MyDataTbl.Rows[N1]["item_description"].ToString();
//MyDRw["item_code"] = MyDataTbl.Rows[N1]["item_code"].ToString();
//MyDRw["hsn_code"] = MyDataTbl.Rows[N1]["hsn_code"].ToString();
//MyDRw["item_image"] = MyDataTbl.Rows[N1]["item_image"];
//MyDRw["item_units"] = MyDataTbl.Rows[N1]["item_units"].ToString();
//MyDRw["item_rate"] = MyDataTbl.Rows[N1]["item_rate"].ToString();
//MyDGVItemDtb.Rows.Add(MyDRw);
.MyDataGrid2.Visible = false;
if (.MyDataGrid2.Rows.Count != 0) {
.MyDataGrid2.ClearSelection();
.MyDataGrid2.BeginEdit(false);
.MyDataGrid2.Visible = true;
}
//myDataGrid1.BeginEdit(true);
//myDataGrid1.Rows[0].Cells[1].Selected = true;
myDataGrid1.CurrentCell = myDataGrid1.Rows[0].Cells[1];
myDataGrid1.Rows[0].Selected = true;
myDataGrid1.Rows[0].Cells[1].Selected = true;
myDataGrid1.Select();
myDataGrid1.Focus();
//myDataGrid1.CurrentCell.Selected = true;
//myDataGrid1.BeginEdit(true);
}
}