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

Headers in databound grid

I have created a databound grid which implements a hierarchical structure between two input tables to achieve the collaps/expand feature. I have redesigned the header rows/columns to show other data then the default. In the first header row I have created a covered range cell. In the PrepareViewStyleInfo handler I set the backround image on this "Covered range cell" but nothing shows up in the grid. Any idea why? When I set backround color it works. private System.Windows.Forms.PictureBox picOCInputs; // Fix Header if ((e.RowIndex == 0 && e.ColIndex == 4)) { Bitmap bmpOC = new Bitmap(picOCInputs.Image); bmpOC.MakeTransparent(bmpOC.GetPixel(1, 1)); picOCInputs.Image = (Image) bmpOC; e.Style.CellType = "Header"; e.Style.ApplyText(""); e.Style.BackgroundImage = picOCInputs.Image; } If I set the BackgroundImage in a covered cell in an unbound grid it works fine. -Tommy-

17 Replies

AD Administrator Syncfusion Team January 6, 2004 11:20 AM UTC

Try setting this property as well: e.Style.Interior = Syncfusion.Drawing.BrushInfo.Empty; This turns off some drawing optimization code that could be interfering with drawing the bitmap background.


TN Tommy Norman January 6, 2004 03:11 PM UTC

Thanks clay, It didn''t work but it was because I forgot to add the picturebox to this particular form where I put the databounded grid. It was all my fault, sorry about that. However I have another question: I''m trying to use the databoundgrid only to get the collaps/expand feature as I previously told you. The problem is that I have to missuse the databound grid quite alot the manage the format of the grid I need so I''d radher go back to the unbound grid where I have more freedom. Do you happend to have an easy sample on how to implement a collaps/expand feature in the unbound grid instead. Regards -Tommy- >Try setting this property as well: > >e.Style.Interior = Syncfusion.Drawing.BrushInfo.Empty; > > >This turns off some drawing optimization code that could be interfering with drawing the bitmap background.


AD Administrator Syncfusion Team January 6, 2004 04:51 PM UTC

Handling collapsing rows in a GridControl is possible, but does take some coding. There is one sample we ship, Syncfusion\Essential Suite\Grid\Samples\In Depth\VirtTreeGrid, that has collapsible rows. Here are a couple of more samples to give you some ideas. One is a treegrid implementation with methods like AddNode to let you construct your collapsible datasource is a tree like manner. (The sample we ship does not have this type of interface and requires that you set up some type collapsible datastructure like the one in the sample.) 2TreeGridSamples_9661.zip


TN Tommy Norman January 7, 2004 06:32 AM UTC

Thanks clay, It looks like some work to make it look good. I think I''ll go on with the databoundgrid for the moment. Another question: As I told you previous I redesign the headers via the gridDataBoundGrid1_PrepareViewStyleInfo handler. The problem is that it looks like an ugly hack after I have put in what I need to. I tried to override the headers instead by accessing the databoundgrid directly but that doesn''t seem to work for some reason. This is what I''m trying to do: for (int z = 0; z < noOfBinInModules; z++) { //Add a covered range for header bitmaps gridModel.CoveredRanges.Add(GridRangeInfo.Cells(0, 4 + (z * noofOCChannelsPerModule), 0, 3 +((z+1) * noofOCChannelsPerModule))); gridDataBoundGrid1[0, 4 +( z * noofOCChannelsPerModule)].CellType = "Header"; gridDataBoundGrid1[0, 4 +( z * noofOCChannelsPerModule)].ApplyText(""); //Stretch the picture gridDataBoundGrid1[0, 4 +( z * noofOCChannelsPerModule)].BackgroundImageMode = GridBackgroundImageMode.StretchImage; //Put in the picture into the cell gridDataBoundGrid1[0, 4 +( z * noofOCChannelsPerModule)].BackgroundImage = pictureBox1.Image; } In an unbound grid this works. Regards -Tommy-


AD Administrator Syncfusion Team January 7, 2004 08:35 AM UTC

I do not know of a way around this. In a GridDataBoundGrid, the header style information is provided dynamically from the basestyles and the GridBoundColumn.HeaderText. (This means the look does not reflect any style information you try to store in a particular grid cell.) So, if you want to change the look of particular cells, then you will have to hook into this dynamic architecture. This means you have to provide the style information in an event, either Model.QueryCellInfo or PrepareViewStyleInfo.


GG Gene Gorokhovsky January 7, 2004 12:57 PM UTC

You can try to paint over headers. Here is how I added support for ImageIndex handling to the row headers (I need it to draw level "error" icon in a grid dervied from GDBG, which is set in OnPrepareViewStyleInfo) protected override void OnCellDrawn(Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e) { base.OnCellDrawn (e); if ( (e.ColIndex == 0) && ( e.RowIndex != 0 ) ) { if ( e.RowIndex == this.CurrentCell.RowIndex ) { GridDataBoundRowHeaderCellRenderer.PaintIcon(e.Graphics, e.Bounds, Point.Empty, "SFARROW.BMP", e.Style.TextColor); } // draw our image on top row header if(this[e.RowIndex, 0].ImageIndex != -1) { GridStaticCellRenderer.DrawImage(e.Graphics, this.TableStyle.ImageList, this[e.RowIndex, 0].ImageIndex, e.Bounds); } } if ( (e.RowIndex == 0) && ( e.ColIndex != 0 ) ) { // draw our image on top of column header if(this[0, e.ColIndex].ImageIndex != -1) { GridStaticCellRenderer.DrawImage(e.Graphics, this.TableStyle.ImageList, this[0, e.ColIndex].ImageIndex, e.Bounds); } } }


DA Dan June 23, 2004 08:34 PM UTC

Clay - When I run the enclosed sample (VirtGridWithCollapsibleRows), I get an exception at the call to this.Controls.AddRange(new System.Windows.Forms.Control[] {this.gridControl1}); Error message: ---------------- A first chance exception of type ''System.NullReferenceException'' occurred in Unknown Module. Additional information: Object reference not set to an instance of an object. ---------------- Any thoughts on what''s happening here? I''ve had this happen with various other samples that I''ve tried -- always fail with same message at the Controls.Add(...) call. Thanks!


AD Administrator Syncfusion Team June 23, 2004 08:38 PM UTC

Did you include your sample? I did not see it in your post.


DA Dan June 23, 2004 09:01 PM UTC

sorry - I meant the sample you enclosed higher up in the post. "2TreeGridSamples_9661.zip" just using something that obviously *should* work, but generates exception for me.


AD Administrator Syncfusion Team June 23, 2004 09:30 PM UTC

What version of our libraries are you using? I just unzipped that sample and tried it in 2.0.5.1, and it seemed ok. You might open up the prject references, remove Grid and Shared, and then readd them to see if that straightens this out.


DA Dan June 23, 2004 09:30 PM UTC

also have the same problem with the sample app posted in this thread http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=13183 (BitmapInPM)


DA Dan June 23, 2004 09:32 PM UTC

using 1.6.1.8 of the Grid control. Just tried removing references and re-adding them in the BitmapInPM sample, and no difference. Is this a 2.0 based sample?


AD Administrator Syncfusion Team June 23, 2004 09:59 PM UTC

When I run the sample in this thread using 1618, I get 2 syntax errors (for two pixel scrolling properties that are not in 1618). If I comment out those lines, the project compiles and runs for me in 1618. You might try running the Assembly Manager (from teh Syncfusion Start menu) and select the default prebuilt files. This may reset things, allowing these projects to build for you. If that does not work, you might try uninstalling and then reinstaling to see it that fixes things.


DA Dan June 24, 2004 01:14 PM UTC

Hmm - tried all that - still not working. Had the Essential Grid eval installed, uninstalled it. Uninstalled Essential Grid 1.6.1.8, rebooted, checked GAC, no syncfusion products. Reinstalled 1.6.1.8 Grid product, ran Assembly manager, "default prebuilt" already selected. I''ve tried both 1.0 & 1.1 framework radio buttons. Check GAC, now syncfusion.grid and .shared in there, pointing to the correct install dir for the DLLs. Still get exception on the call to Controls.Add(...) (I too have to comment out the two "pixel" lines of code) Any other ideas? I think there''s source for the grid somewhere, would it show me anything if I build against that?


AD Administrator Syncfusion Team June 24, 2004 01:28 PM UTC

If you purchased the source code version of our products, you can use the Assembly manager to build debug versions of our libraries. Then running the sample in debug should give you a call stack you can use to check information in our source. Does your GAC have any policy.Syncusion files in it? If so, you might delete those to see if they might be confusing the framework as to Syncfusion versions.


DA Dan June 24, 2004 03:22 PM UTC

So I used AssemblyManager to point to the debug assemblies (selected full rebuild, and 1.1 framework). Ran the sample in debug mode, and it works! I don''t step into any source, since this call is to System.Windows.Forms, not to the grid. Use AssemblyManager to switch back to the prebuilt release and it still works! Argh, so now I don''t know how I got into the bad state. What are the policy.1.6.Syncfusion files for? Can I safely delete them? I''m trying to understand the Assembly Manager, and see that when I switch between debug and prebuilt, and run the sample, the DLL that gets pulled into the process space is always the same: C:\WINDOWS\assembly\GAC\syncfusion.grid\1.6.1.8__3d67ed1f87d44c89 And properties on this file in the GAC always points to file:///C:/Program Files/Syncfusion/Essential Suite/Assemblies/Syncfusion.Grid.dll Assumption: The assembly manager swaps the correct file into that directory, then registers it with the GAC. (I see "A" bit on the files change when I do this...) Is this correct? Final question on this topic (hopefully) :) When choosing the prebuilt release, does it matter what Framework version radio button is chosen? (makes sense to choose this when selecting "full rebuild")


AD Administrator Syncfusion Team June 24, 2004 03:50 PM UTC

> The assembly manager swaps the correct file into that directory, then registers it with the GAC. (I see "A" bit on the files change when I do this...) Is this correct? Yes. To date, there is no specific 1.1 supported features in the Syncfusion code base, so as far as Syncfusion goes, whether you click 1.0 or 1.1 does not matter. Some customers have reported slight increase in performance if you use stick with a single FrameWork version across all your DLLs.

Loader.
Live Chat Icon For mobile
Up arrow icon