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

setting cell values programmatically

Thread ID:





9933 Jan 16,2004 07:19 PM UTC Jan 19,2004 12:56 PM UTC WinForms 5
Tags: GridControl
Colin Lamarre
Asked On January 16, 2004 07:19 PM UTC

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 07:36 PM UTC

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 08:20 PM UTC

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

Colin Lamarre
Replied On January 16, 2004 10:02 PM UTC

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 11:13 AM UTC

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 12:56 PM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon