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

Changing GridDataBoundGrid Cell DataSource at runtime

Thread ID:





11087 Feb 23,2004 04:01 PM UTC Feb 23,2004 05:41 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On February 23, 2004 04:01 PM UTC

I was wondering if anyone could help me change the value of a cell''s datasource, in a GridDataboundGrid, at runtime. I would like to use a default datasouce for the column, but be able to change the datasource if the user checks a box in a column in the same row. I have tried the following, but it does not work: private void gdbServer_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { int row = e.RowIndex; int col = e.ColIndex; if ( col == 2 && row > 0 ) { string sPass = this.gridDataBoundGrid[ row, 3 ].CellValue.ToString(); if ( sPass == "N" ) { e.Style.DataSource = this.dataViewA; } if ( sPass == "Y" ) { e.Style.DataSource = this.dataViewB; } } }

Administrator [Syncfusion]
Replied On February 23, 2004 04:18 PM UTC

Try using the grid.Model.QueryCellInfo event instead of the grid.PrepareViewStyleInfo event. If that does not work for you, you can use the grid.CurrentCellShwoingDropDown event as discussed in this KB, http://www.syncfusion.com/Support/article.aspx?id=567

Administrator [Syncfusion]
Replied On February 23, 2004 05:41 PM UTC

Thanks, the CurrentCellShowingDropDown event worked for me. Here is how I did it, in case anyone else is curious. private void gdbServer_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e) { GridCurrentCell cc = this.gdbServer.CurrentCell; int row = cc.RowIndex; int col = cc.ColIndex; if( col == 2 ) { GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; if( cr != null ) { string sPass = this.gridDataBoundGrid[ row, 3 ].CellValue.ToString(); if ( sPass == "N" ) { ((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = this.dataViewA; } if ( sPass == "Y" ) { ((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = this.dataViewB; } } } }


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