ComponentOne FlexGrid: Merging headers with FixedOnly and details with Spill ?

 How is it possible?

I have a FlexGrid that has a header on 2 lines. Some cols of the first line needs to be merged togheter. This is done easily by setting .AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.FixedOnly

Now, I have added a hierarchy in my grid to display the rows grouped by a column. but this group desciption is very long. So I would like like to set .AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Spill

Any demos of that?
 
 
LVL 71
Éric MoreauSenior .Net ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Eric,

It has been a long time since I used the C1FlexGrid, so it might take a little to get up to speed.  

What version are you using now?

Bob
0
Éric MoreauSenior .Net ConsultantAuthor Commented:
Hi Bob

I still use 2.1.20033.136
0
Bob LearnedCommented:
Eric,

All I have is the Community Version from the VB.NET 2003 Resource Kit.  I don't know how much they changed the model for 2.0, but I'll see if I can remember how to do it with the version that I have.

Bob
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Éric MoreauSenior .Net ConsultantAuthor Commented:
The version I have is the latest upgrade to the Community Version from the VB.NET 2003 Resource Kit available for free (2003-3 if I am not mistaken). So your version should be almost the same as mine.
0
Bob LearnedCommented:
It is slowly coming back ;)

If memory serves me correctly, you can only specify AllowMergingEnum.Free or AllowMergingEnum.Spill but not both.  So you could merge the column headers, but not also spill text over to the next empty cell.

Bob
0
Bob LearnedCommented:
If I am right, we could probably find a way to fake it.

Bob
0
Éric MoreauSenior .Net ConsultantAuthor Commented:
>>you can only specify AllowMergingEnum.Free or AllowMergingEnum.Spill but not both

That's what I found.

>>If I am right, we could probably find a way to fake it.

That's exactly what I'm looking for!
0
Bob LearnedCommented:
Eric,

I gotta get going for the weekend, but this is what I have so far, that sorta, kinda works:

1) I set up the columns so that the 5th column spills into the 6th column.
2) Set DrawMode = OwnerDraw
3) Set AllowMerging = FixedOnly
4) Add this event sink:

  Private Sub fg_OwnerDrawCell(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.OwnerDrawCellEventArgs) Handles fg.OwnerDrawCell

    If e.Col = 4 AndAlso e.Graphics.MeasureString(e.Text, Me.fg.Font).Width > e.Bounds.Width Then
      Dim pen As New Pen(e.Style.Border.Color, 1)
      Dim x1 As Integer = e.Bounds.Left
      Dim x2 As Integer = e.Bounds.Right - 1
      Dim y1 As Integer = e.Bounds.Top
      Dim y2 As Integer = e.Bounds.Bottom - 1
      e.Graphics.DrawLine(pen, x1, y2, x2, y2)
      e.Handled = True
    End If

  End Sub

5) When the text is too long for the cell in Column(4), then the text won't be drawn (e.Handled = True).  What I was thinking is that you use Graphics.DrawString with a layout rectangle for the entire region of both cells for the merge range.  

6) I hope that makes sense.  I'll pick it up later.

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantAuthor Commented:
I have used your idea of setting the DrawMode to OwnerDraw but I kept AllowMerging to Nodes. Then in the OwnerDrawCell event, using DrawString, I span myself the title over many columns.
0
Bob LearnedCommented:
Eric,

Any idea that gets what you want is always acceptable.  Glad I could be of a little help.

Bob
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.