My main windows form contains a grid. The RowEditTemplate opens when the user clicks on a row in the grid to allow for edits. I have a "Create folder" button on the RowEditTemplate, whose code-behind will instantiate and open a second Windows form (only contains textboxes). I'm prepopulating the values in the second Windows form based on the values in the RowEditTemplate. The fields on the second Windows form are entered by the user then clicks the "Save" button. I'd like to take the values entered on the second Windows form and create a new row in the grid on the main windows form so the newly-created row can be displayed. I am able to save it successfully to the datasource, but cannot get it to display as a new row in the grid. The code in my "Create folder" button is:private void btnCreatefolder_Click(object sender, EventArgs e){
RMSStatic.curr_location = (string)this.ultraGridRowEditTemplate3.Row.Cells[this.ugcpSITE_ID_CURRENT2.ColumnKey].Value.ToString(); Additional RMSStatic values being saved here, coming from the RowEditTemplate.... RMSStatic.activeGrid = "FILES"; RMSStatic.keepGrid = this.ultraGridRecordsTempVW;
//This is creating the second form (object) and opens RMSTestWithLogin.AddSubfolder s = new RMSTestWithLogin.AddSubfolder(); s.rmsd = rMSDataSet; s.ShowDialog();}The code in my "Save" button is: private void btnSave_Click(object sender, EventArgs e) { //Add new Subfolder row to grid UltraGridRow aUGRow = RMSStatic.keepGrid.DisplayLayout.Bands[0].AddNew(); aUGRow.Cells["FOLDER_TYPE"].Value = "SUB"; aUGRow.Cells["RECORD_STATUS"].Value = "TEST"; aUGRow.Cells["SITE_ID_CURRENT"].Value = comboCurrLocLkup.Value; aUGRow.Cells["SITE_ID_HOME"].Value = comboHomeLocLkup.Value; aUGRow.Cells["DESCRIPTION"].Value = RMSStatic.desc; aUGRow.Cells["Action"].Value = "Delete"; aUGRow.Cells["BAR_CODE"].Value = RMSStatic.barcode; string record_Type = ""; if (comboRecordType.Value != null) record_Type = comboRecordType.Value.ToString();
aUGRow.Cells["RECORD_TYPE"].Value = record_Type;
rmsd.RECORDS_TEMPVW.AcceptChanges(); this.Close(); } The problem is...the user is able to open the second Windows form and enter the fields OK, but when they click "Save", the record is inserted into the underlying database table (via the "InsertSubfolder" method above), but the grid on the main Windows form is now showing the newly-added record. I'm trying to use the code in btnSave_Click to add the new row in the grid, but it's not showing.
Should I be doing this differently?
Thank you,
Chris
Hi Chris,
You kinda lost me here. The whole point of a RowEditTemplate is to provide the user with a more user-friendly UI to enter data for a row - whether it be an existing row or a new row. So why show a new dialog from the RowEditTemplate? Why not simply use the RowEditTemplate to add the new row?
How would I programmatically add a new row using the RowEditTemplate? I'd like to use the values obtained from the second form to add the new row.