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.

GDBG. How can I add new columns in the grid and

Thread ID:

Created:

Updated:

Platform:

Replies:

13754 May 10,2004 03:46 AM May 14,2004 12:31 AM Windows Forms 8
loading
Tags: GridControl
Silenter
Asked On May 10, 2004 03:46 AM

Hello. I have dataset with two tables are related. Firstly, I want to hide header for Parent table. Furthe, I Added columns to the grid like this: GridHierarchyLevel quotes = gridDataBoundGrid1.Binder.AddRelation(dataset11.Relations[0].RelationName); GridHierarchyLevel root = gridDataBoundGrid1.Binder.RootHierarchyLevel; root.LayoutColumns(new string[] {"Portfolio", "-", "-", "-", "-", "-", "-", "-", "-"}); quotes.LayoutColumns(new string[]{"Symbol", "Compress", "Date", "Open", "High", "Low", "Close", "Volume"}); Now, I want to add new 4 columns Col1, Col2, Col3, Col4 to the nested table and I want to cover it with header "Added Columns". Please see example. This is must be before adding new columns: BeforeAdd_9425.zip And this is must be after adding new columns: AfterAdd_7751.zip Please draw attention , I need to add columns to nested table. Thanks a lot. Best Regards, Slava.

Administrator [Syncfusion]
Replied On May 10, 2004 09:53 AM

Attached is a sample of one way you can do this. It adds an exta row header, and provides teh header text in PrepareViewStyleInfo on demand. forum_addColumns_199.zip

Silenter
Replied On May 11, 2004 11:31 PM

Ok, Thanks. But, when Parent header is hidden I can''t resize columns of nested table. How can i fix it? Regards, Slava.

Administrator [Syncfusion]
Replied On May 12, 2004 01:36 AM

Try including the InsideGrid flag in the grid.ResizeColsBehavior flag. This should let you resize anywhere in the grid, not just on the first header row.

Silenter
Replied On May 12, 2004 07:17 AM

Ok, It works. Thanks. Slava.

Silenter
Replied On May 13, 2004 07:25 AM

Hi again. 1. I Binded dataGrid to datasource. 2. I Added new columns to datasource and grid. 3. And now I can''t type any data in the added columns. How can I fix it? You can test it. Run this example SyncDBGGrid_3180.zip And: 1. Click "Load Data". 2. Click "Add columns". 3. Now try to type anything to the added columns. Regards, Slava.

Administrator [Syncfusion]
Replied On May 13, 2004 07:48 AM

Those added columns are not in your datasource. That means that there is no storage allcated to save anything typed into those cells that don''t have columns in the underlying datasource. If you want to use unbound columns like this, then you will have to handle grid.Model.QueryCellInfo and grid.Model.SaveCellInfo. Additionally, you will have to allocate some storage object to hold the data. (maybe a Hashtable or DataTable or Array or ???) In your QueryCellInfo handler, based on e.ColIndex and e.RowIndex, you would retrieve the requested row and col value from you storage object, and set this value in e.Style.CellValue. In SaveCellInfo, you would go in the opposite direction, getting the value from e.Style.CellValue and storing it into your data storage based on e.RowIndex and e.ColIndex. You can see a sample of using unbound columns in this manner in Grid\Samples\DataBound\GDBGMultiHeader.

Silenter
Replied On May 13, 2004 11:30 PM

Hi, Sorry, But you are not right. Added columns exist in my datasource. for(Int32 i = 0; i < 4; i++) { dataset11.Quote.Columns.Add("asd" + i.ToString(), typeof(Double)); } m_Root.LayoutColumns(new string[] {"Portfolio", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"}); m_Quotes.LayoutColumns(new string[]{"Symbol", "Compress", "Date", "Open", "High", "Low", "Close", "Volume", "asd0", "asd1", "asd2", "asd3"});

Administrator [Syncfusion]
Replied On May 14, 2004 12:31 AM

I am sorry. You are correct, I missed that code. Here is your sample back modified to allow the changes to take. To get the grid to be aware of the added columns, the code essentially rebinds the grid. I also added to lines like grid.BeginUpdate/EndUpdate and grid.Binder.SuspendBinding/ResumeBinding. The rebinding code fits into the scheme you were trying to use. Another option entirely might be to use the DataSet.Merge command to add the additional columns to the table. I did not actually try this, so I am not sure if you would still have to do this rebinding to get this to work also. (You may as you are actually changing the child table in the relation.) SyncDBGGrid_1814.zip

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.

;