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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GDBG not resetting after schema change

Thread ID:

Created:

Updated:

Platform:

Replies:

28117 Apr 25,2005 01:56 PM UTC May 13,2005 12:16 PM UTC WinForms 6
loading
Tags: GridControl
Brandon Richter
Asked On April 25, 2005 01:56 PM UTC

Hi, There have been several posts on this topic before and I''ve tried all the suggestions, but it just isn''t happening. I have a GDBG bound to a table in a dataset. The schema of the table changes after a few buttons are pressed and I''m trying to get the grid to drop everything it has and reinitialize itself. Below are the statements I''ve tried calling to do this, but when loading a second time, it keeps the columns that were present in the first load. data.Reset() ''data is a dataset data = db.UnthreadedQuery(sql_string) ''returns data in the ''results'' datatable data.Tables("results").Columns.Add("S", GetType(String)) ''start GRID UPDATE Me.Cursor = Cursors.WaitCursor datagrid1.BeginUpdate() datagrid1.DataSource = Nothing datagrid1.DataMember = Nothing ''datagrid1.ResetProperties() datagrid1.Model.ResetVolatileData() ''datagrid1.Initialize() ''datagrid1.Model.Refresh() datagrid1.DataSource = data.Tables("results").DefaultView() datagrid1.Model.Cols.MoveRange(datagrid1.Binder.NameToColIndex("S"), 1) datagrid1.Model.ColWidths.SetSize(datagrid1.Binder.NameToColIndex("S"), 20) datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(2, datagrid1.Model.ColCount)) datagrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header" ''show numbers in the row headers datagrid1.Binder.AutoInitCellTypes = False datagrid1.Binder.EnableEdit = False datagrid1.Binder.InitializeColumns() datagrid1.TableStyle.Trimming = StringTrimming.EllipsisCharacter datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.NoShrinkSize) datagrid1.ListBoxSelectionMode = SelectionMode.MultiExtended datagrid1.AllowDragSelectedCols = True datagrid1.EndUpdate() datagrid1.Refresh() Me.Cursor = Cursors.Arrow Thanks for your help, Brandon

Administrator [Syncfusion]
Replied On April 25, 2005 02:57 PM UTC

Calling data.Reset actually removes all tables from the DataSet. Does db.UnthreadQuery add them back? Here is a sample that uses dataset.Reset to display new datasources in a grid. But it does have to re-add the Datatable(s) after the Reset. http://www.syncfusion.com/Support/user/uploads/GDBG_ResetDatasource_504298cb.zip

Brandon Richter
Replied On April 25, 2005 05:52 PM UTC

Yes, the unthreaded query function adds the "results" datatable to the dataset if it does not already exist. I have verified this by outputting data.tables("results").columns.count to a textbox after the grid refresh/update event is raised.

Pua Eng Heng
Replied On April 26, 2005 07:44 AM UTC

Hi Clay, I have encountered similar problem (which I post in another thread). Using your sample, I could reproduce similar problem. This is whay I did. Click the ResetGrid button until the grid show 2 columns. Now change the column sequnce by dragging the column header. Then click the ResetGrid button many time, you will find that the data changes but number of column shown in the grid always remain 2 columns. I think the grid also needs some kind of reset ??? Regards Pua Eng Heng >Hi, > >There have been several posts on this topic before and I''ve tried all the suggestions, but it just isn''t happening. I have a GDBG bound to a table in a dataset. The schema of the table changes after a few buttons are pressed and I''m trying to get the grid to drop everything it has and reinitialize itself. Below are the statements I''ve tried calling to do this, but when loading a second time, it keeps the columns that were present in the first load. > > >data.Reset() ''data is a dataset > >data = db.UnthreadedQuery(sql_string) ''returns data in the ''results'' datatable >data.Tables("results").Columns.Add("S", GetType(String)) > >''start GRID UPDATE >Me.Cursor = Cursors.WaitCursor >datagrid1.BeginUpdate() > >datagrid1.DataSource = Nothing >datagrid1.DataMember = Nothing > >''datagrid1.ResetProperties() >datagrid1.Model.ResetVolatileData() >''datagrid1.Initialize() >''datagrid1.Model.Refresh() > >datagrid1.DataSource = data.Tables("results").DefaultView() > >datagrid1.Model.Cols.MoveRange(datagrid1.Binder.NameToColIndex("S"), 1) >datagrid1.Model.ColWidths.SetSize(datagrid1.Binder.NameToColIndex("S"), 20) >datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(2, datagrid1.Model.ColCount)) > >datagrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header" ''show numbers in the row headers >datagrid1.Binder.AutoInitCellTypes = False >datagrid1.Binder.EnableEdit = False >datagrid1.Binder.InitializeColumns() > > > >datagrid1.TableStyle.Trimming = StringTrimming.EllipsisCharacter >datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.NoShrinkSize) > >datagrid1.ListBoxSelectionMode = SelectionMode.MultiExtended >datagrid1.AllowDragSelectedCols = True > >datagrid1.EndUpdate() >datagrid1.Refresh() >Me.Cursor = Cursors.Arrow > > >Thanks for your help, >Brandon

Brandon Richter
Replied On April 28, 2005 02:27 PM UTC


Brandon Richter
Replied On May 12, 2005 08:23 PM UTC


Administrator [Syncfusion]
Replied On May 13, 2005 12:16 PM UTC

Before you reset the datasource, clear the grid.GridBoundColumns collection if they have been used.
this.ds.Tables.Add(dt);
if(this.gridDataBoundGrid1.GridBoundColumns.Count > 0)  //added
	this.gridDataBoundGrid1.GridBoundColumns.Clear();   //added
this.gridDataBoundGrid1.DataSource = ds.Tables["MyTable"];

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.

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

;