c# - Paint DataGridView ColumnHeader with it's default gradient styles -


I have DataGridView setup similar to the left. I have some columns that are used to show images / errors. It works fine, my problem is that I really do not like the split of each section of those columns. Ideally I want to paint the column headers as if they are a column header, so it looks just like the one on the right.

Is not it a way to use some internal datagrid visual rendering methods, not know?

Enter image details here

I tried to see this To see that this is actually a column header painting, but I can not find anything, the datagrid reflects the visual code. I thought what I was doing and could be able to expand the boundaries of the cell to cover each of the first four columns.

Summary:

What do I have:

What do I need:

Override and paint the event> code> randex for cellpinning to -1, as you wish.

Alternatively, you can create a new class that comes from the DataGridViewColumnHeaderCell and overrides the color scheme for it, but there are some other steps (which I Do not miss outrageous) You have to get a grid to use your derived class which is a pain.

Edit:

Here's a link that tells you better:

Excerpt on Link Dying:

In Paint Override , You will do something like this:

  if (E. rindex == -1) {e.Graphics.FillRectangle (brush.blue, e. colobound); E. Paint (E.Clipband, (DatagridViewPintparts.Alli and Datagram GridViewPaintPart. Background)); E.Handled = True; }  

If you go with class override, keep this in mind:

If you create your own class, then you Either set a header header property as an example of your custom header class (you want to copy some properties such as text from the header cell which is present before the value is overwritten)). You can also create a custom column square that sets the headersell to your custom cell in the constructor.

If you want to do it for all the columns, then handle the additional events in the column, so you know that you have a custom header cell.

All of this is in the edit section of my answer in the above link for Mark Rideout, DataGride Visual Program Manager at least 2006.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -