Wednesday, July 25, 2012

Show Tooltip on Datagridview of relevant record in c#


 private void dgvItemList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            string newLine = Environment.NewLine;
            string DocNo, Date;
            if (e.ColumnIndex == 1)
            {
                DataGridViewCell cell = dgvItemList.Rows[e.RowIndex].Cells[e.ColumnIndex];
                if (e.Value.Equals("H"))
                {                        
                            string ItemNo = dgvItemList[0, e.RowIndex].Value.ToString();
                            DataTable dtItemNo = App_Code.Class1.TooltipItemList(ItemNo);
                            if (dtItemNo.Rows.Count > 0)
                            {
                                DocNo=dtItemNo.Rows[0]["Invoice No"].ToString();
                                Date = dtItemNo.Rows[0]["Date"].ToString();
                                string Unit = dtItemNo.Rows[0]["Unit Price"].ToString();
                                cell.ToolTipText ="InvoiceNo: "+DocNo+" Date: "+Date+" Price:"+Unit;
                            }    
                        }
                    }
                      
            }

No comments:

Post a Comment