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

How do you rebind to a GDBG control?

Hi, I''ve bound a dataset to the GDBG, and intermittently, I change the dataset (records, values, etc). The GDBG is nnot editable, and I need to keep refreshing the view with the changed dataset, so as to invoke the PrepareViewStyleInfo event of the GDBG. What I''m doing at the moment is as follows... Could you look at it and let me know if this is the right way of doing it? private void SetDataBinding() { this.dgTest.DataSource = _dsMain; this.dgTest.DataMember = DAF_MAIN_REPORT; GridModel gridModel = dgTest.Model; GridModelDataBinder binder = dgTest.Binder; gridModel.BeginUpdate(); binder.LayoutColumns(new string[] { "CurrentStatusDate","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "CurrentStatusName", "Target", "-","-", "Acquirer", "-","-", "EquityConsideration", "EnterpriseConsideration", "MinimumFee", "GSFee", "GSEngagementFeePercent", "GSBreakUpFeePercent", ".", "ProductName","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "TeamLeads", "-", "-", "TeamLeads", "-", "-", "HoursAssigned", "-","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "ExclusionComments", "-","-","-","-","-","-","-","-","-","-","-","-", ".", "Comments", "-","-","-","-","-","-","-","-","-","-","-","-" }); this.dgTest.HighlightCurrentColumnHeader = false; //this.dgTest.AllowSelection = GridSelectionFlags.None; this.dgTest.SortBehavior = GridSortBehavior.SingleClick; gridModel.EndUpdate(true); //gridModel.Refresh(); //this.dgTest.VerticalThumbTrack = true; this.dgEx.DataSource = _dsEx; this.dgEx.DataMember = DAF_EXCL_REPORT; gridModel = dgEx.Model; binder = dgEx.Binder; gridModel.BeginUpdate(); binder.LayoutColumns(new string[] { "CurrentStatusDate","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "CurrentStatusName", "Target", "-","-", "Acquirer", "-","-", "EquityConsideration", "EnterpriseConsideration", "MinimumFee", "GSFee", "GSEngagementFeePercent", "GSBreakUpFeePercent", ".", "ProductName","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "TeamLeads", "-", "-", "TeamLeads", "-", "-", "HoursAssigned", "-","DummyCol","DummyCol","DummyCol","DummyCol","DummyCol", ".", "ExclusionComments", "-","-","-","-","-","-","-","-","-","-","-","-", ".", "Comments", "-","-","-","-","-","-","-","-","-","-","-","-" }); this.dgEx.HighlightCurrentColumnHeader = false; //this.dgTest.AllowSelection = GridSelectionFlags.None; this.dgEx.SortBehavior = GridSortBehavior.SingleClick; //gridModel.ColWidths.ResetRange(1, gridModel.ColCount - 1); //gridModel.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, this.dgTest.ViewLayout.LastVisibleRow), GridResizeToFitOptions.IncludeHeaders|GridResizeToFitOptions.ResizeCoveredCells|GridResizeToFitOptions.NoShrinkSize); gridModel.EndUpdate(true); //gridModel.Refresh(); //this.dgTest.VerticalThumbTrack = true; SetDealCount(); this.dgTest.Binder.InternalColumns[COL_COMMENTS].StyleInfo.WrapText = true; } Thanks.

5 Replies

AD Administrator Syncfusion Team August 25, 2005 01:46 PM UTC

I may be misunderstanding what you are asking. If you are only changing the values in the DataTables (not changing the schema, just the contents of the DataTables), then to trigger PrepareViewStyleInfo on the whole grid, then all you shuld have to do is call grid.Refresh(). You do not have to reset the DataSource or layout (unless you actuall changed the DataSource or layout). So, I think you should only have to do the code you listed initially, and there after you would do a grid.Refresh. Now if you are calling a DataSet.Meger or something of that nature to change the data, then you may have to do other work. But if all you are doing is modyfying records in existing tables, then calling grid.Refresh should be sufficient.


AP Atith Pagdi August 26, 2005 10:34 AM UTC

Look, what I need to do is bind the dataset to the GDBG. And, depending on a certain column in each row of the DataTable, I need to specify the font colour in certain cells. I''m using the currency manager class for this (to access the datarow to which the cell is bound). Here''s the code I''m using: CurrencyManager cm = (CurrencyManager)this.BindingContext[this.dgTest.DataSource, DAF_MAIN_REPORT]; DataRow dr = ((DataRowView)cm.Current).Row; Using the value of a col in this datarow, dr["IsPublicProject"], I check the e.RowIndex and ColIndex of the cell in the prepareviewstyleinfo event handler. If the row and column indices match the indices of the cell I need to change, then I change the color. The problem is that irrespective of the value of the column in dr, all the cells'' font is getting set to the different color the first time the form is loaded. This column in the dr takes ''Y'' and ''N'' values. If I go on clicking on different rows that have ''N'', then there''s no change to the font. But the moment I click on a row that has ''Y'', the font changes. Why do you think this is happening? My requirement is that each row (I''m using a multirow record in the GDBG) should be formatted depending on this column in the dr. For starters, this is not happening according to the requirement. Secondly, when I switch between rows (select different rows) this setup changes. Is the right way of setting the style using the PrepareViewStyleInfo event handler? Thanks, Atith >I may be misunderstanding what you are asking. > >If you are only changing the values in the DataTables (not changing the schema, just the contents of the DataTables), then to trigger PrepareViewStyleInfo on the whole grid, then all you shuld have to do is call grid.Refresh(). You do not have to reset the DataSource or layout (unless you actuall changed the DataSource or layout). So, I think you should only have to do the code you listed initially, and there after you would do a grid.Refresh. > >Now if you are calling a DataSet.Meger or something of that nature to change the data, then you may have to do other work. But if all you are doing is modyfying records in existing tables, then calling grid.Refresh should be sufficient.


AD Administrator Syncfusion Team August 26, 2005 12:04 PM UTC

Where are you subscribing to PrepareViewStyleInfo? Has this event been subscribed to before the grid displays for the first time? (Put a Console.WriteLine in it to see if it is being hit during the first display).


AP Atith Pagdi August 26, 2005 12:41 PM UTC

There are some questions I have. Is there a number I can reach you at?


AD Administrator Syncfusion Team August 26, 2005 06:12 PM UTC

You can use Direct Trac to submit questions you do not want to post on the forum.

Loader.
Live Chat Icon For mobile
Up arrow icon