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.
Unfortunately, activation email could not send to your email. Please try again.

setting cell values programmatically

Thread ID:





9933 Jan 16,2004 02:19 PM Jan 19,2004 07:56 AM Windows Forms 5
Tags: GridControl
Colin Lamarre
Asked On January 16, 2004 02:19 PM

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.

Colin Lamarre
Replied On 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

Administrator [Syncfusion]
Replied On January 16, 2004 03:20 PM

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

Colin Lamarre
Replied On 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!

Administrator [Syncfusion]
Replied On 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;

Colin Lamarre
Replied On January 19, 2004 07:56 AM

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.