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

Grid ComboBox Refresh wierd behavior

Hi, I am having trouble refreshing values in a databound combobox inside a grid. I am attaching a sample project that shows the behavior. Here is what the problem is: I have a tabControl with 2 tab pages. Both tab pages have databoundgrids, grid1 and grid2. grid1 is bound to dataview dvGrid1 and grid2 is bound to dvGrid2. Grid2 has a combo box as one of its columns. I want to refresh the value of the combo box based on the values entered in grid1. I get the currencyManager of the combobox and call the refresh method after updating the arraylist, which is the datasource for the combo. The wierd behavior I see is: THe combo will refresh as long as tab2 doesn''t get the focus. The following steps explain this: 1. Run the app 2. Without switching to tab2, enter a couple of rows in the grid (enable, name columns) 3. Click on tab2 4. Check that the combo has the values entered on tab1 5. Go back to tab1, enter another row 6. Go back to tab2, the value just entered is not populated. When I call cm.Refresh() on line 224, I see the count is updated with the newly added item, but it just doesn''t show up in the combobox. What am I doing wrong here? Thanks for your support, GridTest_3365.zip

2 Replies

AD Administrator Syncfusion Team May 23, 2005 11:52 AM

The grid does not dynamically reload combobox celltype''s DataSources. It assumes that these data sources are static and once loaded, does not try to reload thm every time. This is done for performance reasons. If you want to force them to be reloaded, you can handle CurrentCellShowingDropDown and do the work there. Here is code that worked for me in your sample.
private void grid2_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridComboBoxCellRenderer cr = this.grid2.CurrentCell.Renderer as GridComboBoxCellRenderer;
	if(cr != null)
	{
		
		object o = cr.ListBoxPart.DataSource;
		cr.ListBoxPart.DataSource = null;
		cr.ListBoxPart.DataSource = o;
	}
}

            


AD Administrator Syncfusion Team May 23, 2005 01:33 PM

That worked great! Thanks again. >The grid does not dynamically reload combobox celltype''s DataSources. It assumes that these data sources are static and once loaded, does not try to reload thm every time. This is done for performance reasons. > >If you want to force them to be reloaded, you can handle CurrentCellShowingDropDown and do the work there. Here is code that worked for me in your sample. > >
>private void grid2_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
>{
>	GridComboBoxCellRenderer cr = this.grid2.CurrentCell.Renderer as GridComboBoxCellRenderer;
>	if(cr != null)
>	{
>		
>		object o = cr.ListBoxPart.DataSource;
>		cr.ListBoxPart.DataSource = null;
>		cr.ListBoxPart.DataSource = o;
>	}
>}
>
            

Loader.
Live Chat Icon For mobile
Up arrow icon