Datagrid ToolTip

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JerryP

    Datagrid ToolTip

    Hi Group,

    Id like to have a tooltip for each col in the datagrid.
    Is there a way to do that ?

    Thanks !

    Jerry


  • Juan Gabriel Del Cid

    #2
    Re: Datagrid ToolTip

    > Id like to have a tooltip for each col in the datagrid.[color=blue]
    > Is there a way to do that ?[/color]

    Check this out (watch for line wrap):


    That shows you how to do it in VB.Net, but it's basically the same code in
    C#.

    Hope that helps,
    -JG


    Comment

    • Jeffrey Tan[MSFT]

      #3
      RE: Datagrid ToolTip


      Hi JerryP,

      Is your application web based or winform?
      I think Juan's link article tells you the way of adding tooltip for column
      header in Web page. (Such as handle itemcreate event)
      But in winform, there is no itemcreate event and the tooltip property is
      also only for web control.

      I think you should do the hit-test yourself in winform.
      To get this down, you should handle in the mousemove event, and use
      System.Windows. Forms.DataGrid. HitTestInfo to get the current columnheader
      or cell.
      Sample code like this:
      //construct a tooltip in Form_load event
      ToolTip toolTip1 = new ToolTip();
      toolTip1.AutoPo pDelay = 5000;
      toolTip1.Initia lDelay = 1000;
      toolTip1.Reshow Delay = 500;
      toolTip1.ShowAl ways = true;

      private void dataGrid1_Mouse Move(object sender,
      System.Windows. Forms.MouseEven tArgs e)
      {
      System.Windows. Forms.DataGrid. HitTestInfo myHitTest;
      myHitTest = dataGrid1.HitTe st(e.X,e.Y);
      if(myHitTest.Ty pe==DataGrid.Hi tTestType.Colum nHeader)
      {
      string tooltiptext="Co lumnHeader"+myH itTest.Column;
      this.toolTip1.S etToolTip(this. dataGrid1, tooltiptext);
      }
      else
      {
      this.toolTip1.S etToolTip(this. dataGrid1, "");
      }
      }

      This works well on my machine. If you still have any question, please feel
      free to tell me.

      Best regards,
      Jeffrey Tan
      Microsoft Online Partner Support
      Get Secure! - www.microsoft.com/security
      This posting is provided "as is" with no warranties and confers no rights.

      --------------------
      | From: "JerryP" <jerryp_vienna@ hotmail.com>
      | Subject: Datagrid ToolTip
      | Date: Fri, 17 Oct 2003 15:26:33 +0200
      | Lines: 10
      | X-Priority: 3
      | X-MSMail-Priority: Normal
      | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
      | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
      | Message-ID: <u5fWKJLlDHA.16 72@TK2MSFTNGP09 .phx.gbl>
      | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
      | NNTP-Posting-Host: blueice1x.de.ib m.com 194.196.100.75
      | Path:
      cpmsftngxa06.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
      ..phx.gbl!TK2MS FTNGP09.phx.gbl
      | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1920 60
      | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
      |
      | Hi Group,
      |
      | Id like to have a tooltip for each col in the datagrid.
      | Is there a way to do that ?
      |
      | Thanks !
      |
      | Jerry
      |
      |
      |

      Comment

      • Jeffrey Tan[MSFT]

        #4
        RE: Datagrid ToolTip


        Hi JerryP,

        Does this resolved the problem?
        If you still have anything unclear, please feel free to let me know, I am
        glad to work with you.

        Best regards,
        Jeffrey Tan
        Microsoft Online Partner Support
        Get Secure! - www.microsoft.com/security
        This posting is provided "as is" with no warranties and confers no rights.

        --------------------
        | X-Tomcat-ID: 110105520
        | References: <u5fWKJLlDHA.16 72@TK2MSFTNGP09 .phx.gbl>
        | MIME-Version: 1.0
        | Content-Type: text/plain
        | Content-Transfer-Encoding: 7bit
        | From: v-jetan@online.mi crosoft.com ("Jeffrey Tan[MSFT]")
        | Organization: Microsoft
        | Date: Mon, 20 Oct 2003 06:07:33 GMT
        | Subject: RE: Datagrid ToolTip
        | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        | Message-ID: <Js#m4BtlDHA.17 72@cpmsftngxa06 .phx.gbl>
        | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | Lines: 59
        | Path: cpmsftngxa06.ph x.gbl
        | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1925 07
        | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
        |
        |
        | Hi JerryP,
        |
        | Is your application web based or winform?
        | I think Juan's link article tells you the way of adding tooltip for
        column
        | header in Web page. (Such as handle itemcreate event)
        | But in winform, there is no itemcreate event and the tooltip property is
        | also only for web control.
        |
        | I think you should do the hit-test yourself in winform.
        | To get this down, you should handle in the mousemove event, and use
        | System.Windows. Forms.DataGrid. HitTestInfo to get the current columnheader
        | or cell.
        | Sample code like this:
        | //construct a tooltip in Form_load event
        | ToolTip toolTip1 = new ToolTip();
        | toolTip1.AutoPo pDelay = 5000;
        | toolTip1.Initia lDelay = 1000;
        | toolTip1.Reshow Delay = 500;
        | toolTip1.ShowAl ways = true;
        |
        | private void dataGrid1_Mouse Move(object sender,
        | System.Windows. Forms.MouseEven tArgs e)
        | {
        | System.Windows. Forms.DataGrid. HitTestInfo myHitTest;
        | myHitTest = dataGrid1.HitTe st(e.X,e.Y);
        | if(myHitTest.Ty pe==DataGrid.Hi tTestType.Colum nHeader)
        | {
        | string tooltiptext="Co lumnHeader"+myH itTest.Column;
        | this.toolTip1.S etToolTip(this. dataGrid1, tooltiptext);
        | }
        | else
        | {
        | this.toolTip1.S etToolTip(this. dataGrid1, "");
        | }
        | }
        |
        | This works well on my machine. If you still have any question, please
        feel
        | free to tell me.
        |
        | Best regards,
        | Jeffrey Tan
        | Microsoft Online Partner Support
        | Get Secure! - www.microsoft.com/security
        | This posting is provided "as is" with no warranties and confers no rights.
        |
        | --------------------
        | | From: "JerryP" <jerryp_vienna@ hotmail.com>
        | | Subject: Datagrid ToolTip
        | | Date: Fri, 17 Oct 2003 15:26:33 +0200
        | | Lines: 10
        | | X-Priority: 3
        | | X-MSMail-Priority: Normal
        | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
        | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
        | | Message-ID: <u5fWKJLlDHA.16 72@TK2MSFTNGP09 .phx.gbl>
        | | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | | NNTP-Posting-Host: blueice1x.de.ib m.com 194.196.100.75
        | | Path:
        |
        cpmsftngxa06.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
        | .phx.gbl!TK2MSF TNGP09.phx.gbl
        | | Xref: cpmsftngxa06.ph x.gbl
        microsoft.publi c.dotnet.langua ges.csharp:1920 60
        | | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        | |
        | | Hi Group,
        | |
        | | Id like to have a tooltip for each col in the datagrid.
        | | Is there a way to do that ?
        | |
        | | Thanks !
        | |
        | | Jerry
        | |
        | |
        | |
        |
        |

        Comment

        • JerryP

          #5
          Re: Datagrid ToolTip

          Jeffrey,

          thanks for the support, yes it works now!

          Jerry

          ""Jeffrey Tan[MSFT]"" <v-jetan@online.mi crosoft.com> wrote in message
          news:7LXf0C4lDH A.1804@cpmsftng xa06.phx.gbl...[color=blue]
          >
          > Hi JerryP,
          >
          > Does this resolved the problem?
          > If you still have anything unclear, please feel free to let me know, I am
          > glad to work with you.
          >
          > Best regards,
          > Jeffrey Tan
          > Microsoft Online Partner Support
          > Get Secure! - www.microsoft.com/security
          > This posting is provided "as is" with no warranties and confers no rights.
          >
          > --------------------
          > | X-Tomcat-ID: 110105520
          > | References: <u5fWKJLlDHA.16 72@TK2MSFTNGP09 .phx.gbl>
          > | MIME-Version: 1.0
          > | Content-Type: text/plain
          > | Content-Transfer-Encoding: 7bit
          > | From: v-jetan@online.mi crosoft.com ("Jeffrey Tan[MSFT]")
          > | Organization: Microsoft
          > | Date: Mon, 20 Oct 2003 06:07:33 GMT
          > | Subject: RE: Datagrid ToolTip
          > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
          > | Message-ID: <Js#m4BtlDHA.17 72@cpmsftngxa06 .phx.gbl>
          > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
          > | Lines: 59
          > | Path: cpmsftngxa06.ph x.gbl
          > | Xref: cpmsftngxa06.ph x.gbl[/color]
          microsoft.publi c.dotnet.langua ges.csharp:1925 07[color=blue]
          > | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
          > |
          > |
          > | Hi JerryP,
          > |
          > | Is your application web based or winform?
          > | I think Juan's link article tells you the way of adding tooltip for
          > column
          > | header in Web page. (Such as handle itemcreate event)
          > | But in winform, there is no itemcreate event and the tooltip property is
          > | also only for web control.
          > |
          > | I think you should do the hit-test yourself in winform.
          > | To get this down, you should handle in the mousemove event, and use
          > | System.Windows. Forms.DataGrid. HitTestInfo to get the current[/color]
          columnheader[color=blue]
          > | or cell.
          > | Sample code like this:
          > | //construct a tooltip in Form_load event
          > | ToolTip toolTip1 = new ToolTip();
          > | toolTip1.AutoPo pDelay = 5000;
          > | toolTip1.Initia lDelay = 1000;
          > | toolTip1.Reshow Delay = 500;
          > | toolTip1.ShowAl ways = true;
          > |
          > | private void dataGrid1_Mouse Move(object sender,
          > | System.Windows. Forms.MouseEven tArgs e)
          > | {
          > | System.Windows. Forms.DataGrid. HitTestInfo myHitTest;
          > | myHitTest = dataGrid1.HitTe st(e.X,e.Y);
          > | if(myHitTest.Ty pe==DataGrid.Hi tTestType.Colum nHeader)
          > | {
          > | string tooltiptext="Co lumnHeader"+myH itTest.Column;
          > | this.toolTip1.S etToolTip(this. dataGrid1, tooltiptext);
          > | }
          > | else
          > | {
          > | this.toolTip1.S etToolTip(this. dataGrid1, "");
          > | }
          > | }
          > |
          > | This works well on my machine. If you still have any question, please
          > feel
          > | free to tell me.
          > |
          > | Best regards,
          > | Jeffrey Tan
          > | Microsoft Online Partner Support
          > | Get Secure! - www.microsoft.com/security
          > | This posting is provided "as is" with no warranties and confers no[/color]
          rights.[color=blue]
          > |
          > | --------------------
          > | | From: "JerryP" <jerryp_vienna@ hotmail.com>
          > | | Subject: Datagrid ToolTip
          > | | Date: Fri, 17 Oct 2003 15:26:33 +0200
          > | | Lines: 10
          > | | X-Priority: 3
          > | | X-MSMail-Priority: Normal
          > | | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
          > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
          > | | Message-ID: <u5fWKJLlDHA.16 72@TK2MSFTNGP09 .phx.gbl>
          > | | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
          > | | NNTP-Posting-Host: blueice1x.de.ib m.com 194.196.100.75
          > | | Path:
          > |
          >[/color]
          cpmsftngxa06.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8[color=blue]
          > | .phx.gbl!TK2MSF TNGP09.phx.gbl
          > | | Xref: cpmsftngxa06.ph x.gbl
          > microsoft.publi c.dotnet.langua ges.csharp:1920 60
          > | | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
          > | |
          > | | Hi Group,
          > | |
          > | | Id like to have a tooltip for each col in the datagrid.
          > | | Is there a way to do that ?
          > | |
          > | | Thanks !
          > | |
          > | | Jerry
          > | |
          > | |
          > | |
          > |
          > |
          >[/color]


          Comment

          Working...