none
datagridview column header with superscript/subscript text RRS feed

  • Question

  • Hi all,

     I have to show superscript/subscript text in  datagridview column header in winform.

     I managed to show superscript/subscript data in datagridview cell, but not able to do same in datagridview column  header.

    Please help.

    regards

    sumedh

    Friday, March 4, 2011 5:51 AM

Answers

  • Hi sumedh,

    Yup, I can understand your request totally. The multi-layered column headers can achieve your request, but maybe not a good solution for you.

    Base on my understanding, in all of the windows form controls, there is only RichTextBox control has the function(SelectionCharOffset property) that can done that easily. According your description, you can done that in datagridview cell, I think you are use the RichTextBox Control to host into the DataGridView cell. So I think you can use that RichTextControl hosts into the datagridview column header too, then you can add your mathematical equations into it.

    Or you can draw a image as "x²", then custom draw it into a label, and host a lable into the DataGridView Header.

    If these can not meet your reuquest, I suggest to find some third-part component that maybe can reach your request. But as It is not MicroSoft's, so I am not sure whether it can work well in your project.


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aspen VJ Monday, March 14, 2011 9:15 AM
    Wednesday, March 9, 2011 6:53 AM

All replies

  • Hi smedh,

    Base on your description, It seems that you want to achieve multi-layered column headers in DataGridView. If so, I think you should custom paint the headercell in the datagridview through handle the DataGridView's Paint and CellPaint event.

    Here is a link quite similar to yours.http://social.msdn.microsoft.com/forums/en-us/winformsdesigner/thread/A4D21501-5A54-49B9-9D92-547B8A8DAAE4

    And here is a link about how to implement multi-layered column headers in DataGridView.
    http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e/#faq6


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Edited by Aspen VJ Wednesday, March 9, 2011 6:18 AM
    Tuesday, March 8, 2011 2:10 AM
  • Hi Vin,

    Thanks for your comments.

    I am not looking for multi-layered column headers.

    I have to display some mathematical equations  like [  x²  ] in datagridview column header.

     

    regards

    sumedh

    Tuesday, March 8, 2011 11:09 AM
  • Hi sumedh,

    Yup, I can understand your request totally. The multi-layered column headers can achieve your request, but maybe not a good solution for you.

    Base on my understanding, in all of the windows form controls, there is only RichTextBox control has the function(SelectionCharOffset property) that can done that easily. According your description, you can done that in datagridview cell, I think you are use the RichTextBox Control to host into the DataGridView cell. So I think you can use that RichTextControl hosts into the datagridview column header too, then you can add your mathematical equations into it.

    Or you can draw a image as "x²", then custom draw it into a label, and host a lable into the DataGridView Header.

    If these can not meet your reuquest, I suggest to find some third-part component that maybe can reach your request. But as It is not MicroSoft's, so I am not sure whether it can work well in your project.


    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Aspen VJ Monday, March 14, 2011 9:15 AM
    Wednesday, March 9, 2011 6:53 AM