We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

setting cell values programmatically

Hi, I''m trying to set some cells with values once a selection is made from a drop down grid in the first colunm. Here is a snip of the code: private void CurrentCellEditingComplete(object o, EventArgs e) { String usrcode; int row; if (this.gridDataBoundGrid1.CurrentCell.ColIndex == 3) { row = this.gridDataBoundGrid1.CurrentCell.RowIndex; usrcode = ap(this.gridDataBoundGrid1.Model[row, 3].CellValue.ToString()); this.gridDataBoundGrid1.Model[row, 5].CellValue = GTHub.utils.getsval("select max(description) from accodes where usrcode =" + usrcode).Trim(); this.gridDataBoundGrid1.Model[row, 4].CellValue = GTHub.utils.getsval("select max(acctcode) from accodes where usrcode =" + usrcode); this.gridDataBoundGrid1.Model[row, 2].CellValue = Convert.ToInt64(this.comboBoxExt1.Text); this.gridDataBoundGrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, 20), GridResizeToFitOptions.NoShrinkSize); } } private void gridDataBoundGrid1_Leave(object sender, System.EventArgs e) { this.gridDataBoundGrid1.CurrentCell.EndEdit(); this.CurrentCellEditingComplete(null, null); } It''s weird, it puts the first value in the right place, but the next 2 are put in a new row with the rest of the cols null. If i rearange them the same thing happens, the first is good, the next 2 aren''t. then saving with an sqladapter.update of course messes up the table with these 2 rows. any explanation? thanks.

5 Replies

CL Colin Lamarre January 16, 2004 02:36 PM

Forgot to mention that this behavior only happens when a row other than the current row is used to click away from the drop down col. If i click on the same row it works fine. Using v1.6.1.8


AD Administrator Syncfusion Team January 16, 2004 03:20 PM

Try doing your code in CurrentCellValidating (or CurrentCellMoving). These occur earlier than moving process than CurrentCellEditingComplete.


CL Colin Lamarre January 16, 2004 05:02 PM

Hi, i tried a few other events like currentcellchanged etc, i just tried the validating one. the problem is that the cell value isn''t set to the new drop down choice yet. that''s why i went with CurrentCellEditingComplete. how would you get the new value inside these other events? TIA!


AD Administrator Syncfusion Team January 19, 2004 06:13 AM

In CurrentCellValidating, you get the current value from the Renderer. GridCurrentCell cc = this.grid.CurrentCell; string newValue = cc.Renderer.ControlText;


CL Colin Lamarre January 19, 2004 07:56 AM

That worked! thanks alot! you can close the ticket i just opened...

Loader.
Live Chat Icon For mobile
Up arrow icon