G
Guest
I have been on newsgroup for week. I have seen anything that will help me. Basically, I have a form with a datagrid that can be sorted or unsorted (it is up to the user). Then, I display the data of the selected row in textboxes on dialog that execute by the user press a button. The following code works if I do not sort the datagrid before I press the button to bring up the dialog. It is when I sort it the datagrid I have the issue
private void Frm_CustomerAU_Load(object sender, System.EventArgs e
Frm_Customers frmCustomers= (Frm_Customers) this.Owner;
CurrencyManager currencyMgr = (CurrencyManager)this.BindingContext[frmCustomers.tableInfoDG.DataSource, "Table"]
currencyMgr.Position = frmCustomers.tableInfoDG.CurrentRowIndex
DataRow currentRow = ((DataRowView)currencyMgr.Current).Row
txtBxCompanyName.Text= currentRow["CompanyName"].ToString()
I have also tried using the following code to bind the table to the textbox and I get the same result
txtBxCompanyName.DataBindings.Add("Text", frmCustomers.tableInfoDG.DataSource, "Table.CompanyName")
I believe it has something to do what I am setting CurrencyManager position to ( currencyMgr.Position = frmCustomers.tableInfoDG.CurrentRowIndex. I know I need it to be the position of the underlying table in order to get the selected position in the datagrid. I just do not know how to get the position. By the way, this is C
Any help would be greatly appreciated
private void Frm_CustomerAU_Load(object sender, System.EventArgs e
Frm_Customers frmCustomers= (Frm_Customers) this.Owner;
CurrencyManager currencyMgr = (CurrencyManager)this.BindingContext[frmCustomers.tableInfoDG.DataSource, "Table"]
currencyMgr.Position = frmCustomers.tableInfoDG.CurrentRowIndex
DataRow currentRow = ((DataRowView)currencyMgr.Current).Row
txtBxCompanyName.Text= currentRow["CompanyName"].ToString()
I have also tried using the following code to bind the table to the textbox and I get the same result
txtBxCompanyName.DataBindings.Add("Text", frmCustomers.tableInfoDG.DataSource, "Table.CompanyName")
I believe it has something to do what I am setting CurrencyManager position to ( currencyMgr.Position = frmCustomers.tableInfoDG.CurrentRowIndex. I know I need it to be the position of the underlying table in order to get the selected position in the datagrid. I just do not know how to get the position. By the way, this is C
Any help would be greatly appreciated