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.

Changing GridDataBoundGrid Cell DataSource at runtime

Thread ID:

Created:

Updated:

Platform:

Replies:

11087 Feb 23,2004 11:01 AM Feb 23,2004 12:41 PM Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 23, 2004 11:01 AM

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 11:18 AM

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 12:41 PM

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; } } } }

CONFIRMATION

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.

;