Esempio n. 1
0
 private void ActivityGridCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.RowIndex < 0 || e.ColumnIndex < 0)
         return;
     e.Value = string.Empty;
     e.FormattingApplied = true;
 }
Esempio n. 2
0
private void cellformatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if(grid.Columns[e.ColumnIndex].Name == "lane_id")
{
rvalue = Convert.ToInt32(e.Value);
//e.CellStyle.BackColor = Color.Red;
}
if(rvalue < 10)
{
this.grid.Rows[rvalue].DefaultCellStyle.BackColor = Color.Red;
}
else if(rvalue < 20)
{
this.grid.Rows[rvalue].DefaultCellStyle.BackColor = Color.Green;
}
else
{
this.grid.Rows[rvalue].DefaultCellStyle.BackColor = Color.Yellow;
}

}
 /// <summary>
 /// Metodo que cambia el formato de las celdas del grid de detalles de la venta.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// Usuario Creo: Juan Alberto Hernández Negrete.
 /// Fecha Creo: 27 Noviembre 2013 18:31 Hrs.
 /// Usuario Modifico:
 /// Fecha Modifico:
 private void Grid_Resultado_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     e.CellStyle.Font = new System.Drawing.Font("Consolas Black", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 }
 private void dgHistoryWaterFee_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.RowIndex < 0 || e.ColumnIndex < 0)
     {
         return;
     }
     if (dgHistoryWaterFee.Columns[e.ColumnIndex].Name == "INVOICECANCEL")
     {
         object objInvoiceCancel = e.Value;
         if (objInvoiceCancel != null && objInvoiceCancel != DBNull.Value)
         {
             if (objInvoiceCancel.ToString() == "0")
             {
                 e.Value = "正常";//如果有正常状态的发票就不能打印第二次  只能先作废再打印
             }
             else if (objInvoiceCancel.ToString() == "1")
             {
                 e.Value = "冲减作废";
             }
             else if (objInvoiceCancel.ToString() == "2")
             {
                 e.Value = "损坏作废";
             }
             else if (objInvoiceCancel.ToString() == "3")
             {
                 e.Value = "未打作废";
             }
         }
         else
         {
             e.Value = "未打发票";
         }
     }
     if (dgHistoryWaterFee.Columns[e.ColumnIndex].Name == "CHARGETYPEID")
     {
         object objChargeType = e.Value;
         if (objChargeType != null && objChargeType != DBNull.Value)
         {
             if (objChargeType.ToString() == "1")
             {
                 e.Value = "现金";//如果有正常状态的发票就不能打印第二次  只能先作废再打印
             }
             else if (objChargeType.ToString() == "1")
             {
                 e.Value = "作废";
             }
         }
     }
     if (dgHistoryWaterFee.Columns[e.ColumnIndex].Name == "chargeState")
     {
         object objChargeType = e.Value;
         if (objChargeType != null && objChargeType != DBNull.Value)
         {
             if (objChargeType.ToString() == "3")
             {
                 e.Value = "已收费";//如果有正常状态的发票就不能打印第二次  只能先作废再打印
             }
             else if (objChargeType.ToString() == "2")
             {
                 e.Value = "挂账";
             }
             else if (objChargeType.ToString() == "1")
             {
                 e.Value = "未收费";
             }
         }
     }
 }
Esempio n. 5
0
 private void dtDados_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     dtDados.Columns["Descricao"].Width = 350;
 }
Esempio n. 6
0
        //表格内容格式化,设定正负向,类别,区域
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex != dataGridView1.NewRowIndex)
            {
                switch (dataGridView1.Columns[e.ColumnIndex].Name.ToLower())
                {
                case "focuslevel":
                    string txtFocus = dataGridView1.Rows[e.RowIndex].Cells["focuslevel"].Value.ToString();
                    switch (txtFocus)
                    {
                    case "1":
                        e.Value = "置顶";
                        e.CellStyle.ForeColor = Color.Blue;
                        break;

                    case "2":
                        e.Value = "重点关注";
                        e.CellStyle.ForeColor = Color.Red;
                        break;

                    case "3":
                        e.Value = "关注";
                        e.CellStyle.ForeColor = Color.Green;
                        break;

                    case "99":
                        e.Value = "";
                        e.CellStyle.ForeColor = Color.Green;
                        break;
                    }
                    e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    break;

                case "title_link":
                    //设定正负向
                    string title = dataGridView1.Rows[e.RowIndex].Cells["title"].Value.ToString();
                    e.Value = title;
                    break;

                case "part_img":
                    //设定正负向
                    string part = dataGridView1.Rows[e.RowIndex].Cells["part"].Value.ToString();
                    string url  = Application.StartupPath.ToString();
                    if (part.Equals("1"))
                    {
                        url += "\\icons\\u.png";
                    }
                    else
                    {
                        url += "\\icons\\d.png";
                    }
                    e.Value = File.ReadAllBytes(url);
                    break;

                case "kid":
                    switch (dataGridView1.Rows[e.RowIndex].Cells["kid"].Value.ToString())
                    {
                    case "0":
                        e.Value = "常规舆情";
                        break;

                    case "1":
                        e.Value = "敏感舆情";
                        break;

                    case "2":
                        e.Value = "重点舆情";
                        break;

                    case "3":
                        e.Value = "突发舆情";
                        break;
                    }
                    break;

                case "pid":
                    switch (dataGridView1.Rows[e.RowIndex].Cells["pid"].Value.ToString())
                    {
                    case "0":
                        e.Value = "全网";
                        break;

                    case "1":
                        e.Value = "博客";
                        break;

                    case "2":
                        e.Value = "论坛";
                        break;

                    case "3":
                        e.Value = "微博";
                        break;

                    case "4":
                        e.Value = "主流媒体";
                        break;

                    case "5":
                        e.Value = "贴吧";
                        break;

                    case "6":
                        e.Value = "微信";
                        break;

                    case "7":
                        e.Value = "定制";
                        break;
                    }
                    break;

                case "sheng":
                    e.Value = dataGridView1.Rows[e.RowIndex].Cells["sheng"].Value.ToString() + dataGridView1.Rows[e.RowIndex].Cells["shi"].Value.ToString() + dataGridView1.Rows[e.RowIndex].Cells["xian"].Value.ToString();
                    break;
                }
            }
        }
Esempio n. 7
0
 private void uclstGrdItem_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     //uclstGrdItem.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.Yellow;
     //uclstGrdItem.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor = Color.Black;
     //uclstGrdItem.Rows[e.RowIndex].DefaultCellStyle.Font = new Font("verdana", 9);
 }
Esempio n. 8
0
 private void colourGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     //log.Debug("CellFormatting");
 }
Esempio n. 9
0
 private void dtvAgendamento_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }
Esempio n. 10
0
        private void dgvDSNV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colAnhNhanVien")
            {
                try
                {
                    e.Value = new Bitmap(e.Value.ToString());
                }
                catch
                {
                }
            }


            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colNgayVaoLam")
            {
                if (DateTime.Parse(e.Value.ToString()).ToShortDateString() != "01/01/0001")
                {
                    e.Value = DateTime.Parse(e.Value.ToString()).ToShortDateString();
                }
            }

            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colNgayThoiViec")
            {
                if (e.Value != null)
                {
                    e.Value = DateTime.Parse(e.Value.ToString()).ToShortDateString();
                }
            }


            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colGioiTinh")
            {
                if (Convert.ToBoolean(e.Value) == true)
                {
                    e.Value = "Nam";
                }
                else
                {
                    e.Value = "Nữ";
                }
            }

            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colChucVu")
            {
                ChucVu_BUS           bus       = new ChucVu_BUS();
                List <clsChucVu_DTO> lstChucVu = bus.LayDanhSachChucVu();
                clsChucVu_DTO        dtoChucVu = lstChucVu.First(u => u.MaChucVu == e.Value.ToString());
                e.Value = dtoChucVu.TenChucVu;
            }

            if (dgvDSNV.Columns[e.ColumnIndex].Name == "colTrangThai")
            {
                TrangThaiNV_BUS           bus            = new TrangThaiNV_BUS();
                List <clsTrangThaiNV_DTO> lstTrangThaiNV = bus.LayDanhSachTrangThaiNhanVien();
                clsTrangThaiNV_DTO        dtoTrangThaiNV = lstTrangThaiNV.First(u => u.MaTrangThaiNV == Convert.ToInt32(e.Value.ToString()));
                e.Value = dtoTrangThaiNV.TenTrangThaiNV;
            }

            foreach (DataGridViewRow r in dgvDSNV.Rows)
            {
                if (Convert.ToInt32(r.Cells["colTrangThai"].Value) == 2) // Đã nghỉ việc
                {
                    r.DefaultCellStyle.ForeColor = Color.Gray;
                }
                else if (Convert.ToInt32(r.Cells["colTrangThai"].Value) == 3) // Đang chờ vào làm
                {
                    r.DefaultCellStyle.ForeColor = Color.Blue;
                }
                else
                {
                    r.DefaultCellStyle.ForeColor = Color.Black;
                }
            }
        }
Esempio n. 11
0
 private void dgvMemoria_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     //int vermelho = (int)(255 * ((double)dgvMemoria.Rows[e.RowIndex].Cells[e.ColumnIndex].Value - min) / (max - min));
     //e.CellStyle.BackColor = Color.FromArgb(vermelho, 0, 255 - vermelho);
 }
Esempio n. 12
0
 private void DGV_Brief_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     e.CellStyle.SelectionBackColor = Color.FromArgb(220, 217, 217);
     e.CellStyle.SelectionForeColor = Color.Black;
 }
Esempio n. 13
0
        private void ly_sales_contract_detailDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            DataGridView dgv = sender as DataGridView;

            if (e.RowIndex > -1)
            {
                if ((dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType() == typeof(decimal) ||
                     dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType() == typeof(double) ||
                     dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType() == typeof(int)))
                {
                    if (Convert.ToDecimal(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) == 0)
                    {
                        e.Value = "";
                    }
                }
            }
        }
 private void DG_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     DG.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.Bisque;
     DG.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor = Color.Black;
     DG.Rows[e.RowIndex].DefaultCellStyle.Font = new Font("verdana", 9);
 }
Esempio n. 15
0
 private void grdArtigos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }
Esempio n. 16
0
        private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            DataGridView grd      = sender as DataGridView;
            int          RowIndex = e.RowIndex;

            try
            {
                if (RowIndex % 2 == 0)
                {
                    grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.LightBlue; // ColorFromHex("f0f4c3");
                }
                else
                {
                    grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.LightSteelBlue; //  ColorFromHex("050505");
                }

                if (grd.Rows[RowIndex].Cells[13].Value != null)
                {
                    int days2ship = 0;
                    if (int.TryParse(grd.Rows[RowIndex].Cells[13].Value.ToString(), out days2ship) == true)
                    {
                        if (days2ship <= -20)          // Warning: Delayed past 10 days
                        {
                            grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.Red;
                            grd.Rows[RowIndex].DefaultCellStyle.ForeColor = Color.White;
                        }
                        else if (days2ship > -20 && days2ship < -8)          // Less than one week
                        {
                            grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.Yellow;
                            grd.Rows[RowIndex].DefaultCellStyle.ForeColor = Color.Black;
                        }
                    }
                }


                //if (grd.Rows[RowIndex].Cells[13].Value.ToString().ToUpper().Contains("CORR") == true) // Black Corrupt
                //{
                //    grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.Black;
                //    grd.Rows[RowIndex].DefaultCellStyle.ForeColor = Color.White;
                //}
                //else if (grd.Rows[RowIndex].Cells[13].Value.ToString().ToUpper().Contains("FAIL") == true && // Red = Good packet, but bad CRC
                //   (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("READREQ") == true || grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("READRESP") == true ||
                //     grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("WRITEREQ") == true || grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("WRITERESP") == true ||
                //    grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("PINGREQ") == true || grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("PINGRESP") == true))
                //{
                //    grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.Red;
                //    grd.Rows[RowIndex].DefaultCellStyle.ForeColor = Color.White;
                //}
                //else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("READREQ") == true)
                //{
                //    grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("d4e157");
                //}
                //else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("READRESP") == true)
                //{
                //    grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("f0f4c3");
                //}
                //else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("WRITE") == true)
                //{
                //    if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("REQ") == true)
                //    {
                //        grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("e3f2fd");
                //    }
                //    else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("RESP") == true)
                //    {
                //        grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("7986cb");
                //    }
                //}
                //else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("PING") == true)
                //{
                //    if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("REQ") == true)
                //    {
                //        grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("ffff8d");
                //    }
                //    else if (grd.Rows[RowIndex].Cells[8].Value.ToString().ToUpper().Contains("RESP") == true)
                //    {
                //        grd.Rows[RowIndex].DefaultCellStyle.BackColor = ColorFromHex("ffff00");
                //    }
                //}
                //else
                //{
                //    grd.Rows[RowIndex].DefaultCellStyle.BackColor = Color.Black;
                //    grd.Rows[RowIndex].DefaultCellStyle.ForeColor = Color.White;
                //}
            }
            catch (Exception etry)
            {
            }
        }
Esempio n. 17
0
        private void dgvCells_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (dgvCells.DataSource == null)
            {
                return;
            }

            if (dgvCells.IsStatusRow(e.RowIndex))
            {
                e.CellStyle.BackColor = Color.Silver;
                e.CellStyle.Font      = new Font(e.CellStyle.Font, FontStyle.Bold);

                if (dgvCells.Columns[e.ColumnIndex].Name.Contains("Image"))
                {
                    e.Value = Properties.Resources.Empty;
                }

                return;
            }

            DataGridViewRow r = dgvCells.Rows[e.RowIndex];

            switch (dgvCells.Columns[e.ColumnIndex].Name)
            {
            case "grcCellStateImage":
                if ((bool)r.Cells["grcHasCellContent"].Value)
                {
                    e.Value = Properties.Resources.Box_full;
                }
                else
                {
                    e.Value = Properties.Resources.Empty;
                }
                break;

            case "grcLockedImage":
                if ((bool)r.Cells["grcLocked"].Value)
                {
                    e.Value = Properties.Resources.Lock1;
                }
                else
                {
                    e.Value = Properties.Resources.Empty;
                }
                break;

            case "grcForFrames":
                if (r.Cells["grcIsForFrames"].Value == DBNull.Value)
                {
                    e.CellStyle.BackColor     =
                        e.CellStyle.ForeColor =
                            Color.Silver;
                }
                break;

            case "grcIsRankChanged":
                DataRow rd = ((DataRowView)dgvCells.Rows[e.RowIndex].DataBoundItem).Row;
                if (rd != null && Convert.ToInt32(rd["Rank"]) != Convert.ToInt32(rd["PreRank"]))
                {
                    e.Value = Properties.Resources.Edit;
                }
                else
                {
                    e.Value = Properties.Resources.Empty;
                }
                break;
            }

            // неактуальные - курсивом вся строка
            if (!Convert.ToBoolean(r.Cells["grcActual"].Value))
            {
                e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Italic);
            }
        }
Esempio n. 18
0
 private void gvPurchasePlanList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     // dataGridView1.Rows[e.RowIndex].HeaderCell.Value = e.RowIndex + 1.ToString();
 }
 private void DgvListaPreturi_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     e.CellStyle.BackColor = Color.White;
     e.CellStyle.ForeColor = Color.Black;
 }
 private void dgvCliente_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 => (sender as DataGridView).DefaultCellStyle.Format = "C2";
Esempio n. 22
0
 private void DGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     DGrid.Rows[e.RowIndex].Cells["dgRadif"].Value = e.RowIndex + 1;
 }
Esempio n. 23
0
 private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     e.CellStyle.BackColor = Color.FromArgb(28, 30, 32);
 }
Esempio n. 24
0
 private void grdSucursal_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }
 private void dgvResult_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     SetRound(e);
     SetWinner(e);
 }
Esempio n. 26
0
        void DgReportSheet_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
                return;
            }
            if (e.ColumnIndex < startColumnIndex || e.ColumnIndex > endColumnIndex)
            {
                DataGridViewCell cell     = dgReportSheet.Rows[e.RowIndex].Cells["Relation"];
                string           relation = (string)cell.Value;
                if (relation == "Direct Ancestor")
                {
                    e.CellStyle.Font = boldFont;
                }
            }
            else
            {
                DataGridViewCellStyle style = dgReportSheet.DefaultCellStyle;
                DataGridViewCell      cell  = dgReportSheet.Rows[e.RowIndex].Cells[e.ColumnIndex];
                int value = (int)cell.Value;
                styles.TryGetValue(value, out style);
                if (style != null)
                {
                    e.CellStyle.BackColor          = style.BackColor;
                    e.CellStyle.ForeColor          = style.ForeColor;
                    e.CellStyle.SelectionForeColor = e.CellStyle.SelectionBackColor;

                    cell.InheritedStyle.BackColor          = style.BackColor;
                    cell.InheritedStyle.ForeColor          = style.ForeColor;
                    cell.InheritedStyle.SelectionForeColor = cell.InheritedStyle.SelectionBackColor;

                    switch (value)
                    {
                    case 0:
                        cell.ToolTipText = "Not alive at time of census.";
                        break;

                    case 1:
                        if (e.ColumnIndex == C1939.Index)
                        {
                            if (cbCensusSearchProvider.SelectedItem.Equals("Find My Past"))
                            {
                                cell.ToolTipText = $"No census information entered. Double click to search {cbCensusSearchProvider.SelectedItem}.";
                            }
                            else
                            {
                                cell.ToolTipText = $"No census information entered. No search on {cbCensusSearchProvider.SelectedItem} available.";
                            }
                        }
                        else
                        {
                            cell.ToolTipText = $"No census information entered. Double click to search {cbCensusSearchProvider.SelectedItem}.";
                        }
                        break;

                    case 2:
                        cell.ToolTipText = "Census entered but no Lost Cousins flag set.";
                        break;

                    case 3:
                        cell.ToolTipText = "Census entered and not a Lost Cousins year.";
                        break;

                    case 4:
                        cell.ToolTipText = "Census entered and flagged as entered on Lost Cousins.";
                        break;

                    case 5:
                        cell.ToolTipText = "Lost Cousins flagged but no Census entered.";
                        break;

                    case 6:
                        cell.ToolTipText = $"On Census outside {_country}";
                        break;

                    case 7:
                        cell.ToolTipText = $"Likely outside {_country} on census date";
                        break;

                    case 8:
                        cell.ToolTipText = "Known to be missing from the census";
                        break;
                    }
                }
            }
        }
Esempio n. 27
0
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            DataGridViewRow CurrentRow = dataGridView1.Rows[e.RowIndex];

            CurrentRow.HeaderCell.Value = (e.RowIndex + 1).ToString();
        }
Esempio n. 28
0
 private void dgvMarks_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }
        private void DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.Value == null)
            {
                return;
            }
            else if (String.IsNullOrWhiteSpace(e.Value.ToString()))
            {
                return;
            }

            if (e.ColumnIndex == this.dataGridView.Columns["cpuColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM cpus WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim() + " " + dr.GetValue(3).ToString().Trim();
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["memoryColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM memory WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim() + " ";

                        if (!String.IsNullOrWhiteSpace(dr.GetValue(3).ToString()))
                        {
                            info += dr.GetValue(3).ToString().Trim() + "GHz ";
                        }
                        if (!String.IsNullOrWhiteSpace(dr.GetValue(4).ToString()))
                        {
                            info += dr.GetValue(4).ToString().Trim() + "Gb";
                        }
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["motherboardColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM motherboards WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim() + " " + dr.GetValue(3).ToString().Trim()
                                + " " + dr.GetValue(4).ToString().Trim();
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["graphicsCardColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM graphics_cards WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim() + " ";

                        if (!String.IsNullOrWhiteSpace(dr.GetValue(3).ToString()))
                        {
                            info += dr.GetValue(3).ToString().Trim() + "Gb";
                        }
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["hardDriveColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM internal_hard_drives WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim();

                        if (!String.IsNullOrWhiteSpace(dr.GetValue(3).ToString()))
                        {
                            info += " " + dr.GetValue(3).ToString().Trim() + "Gb";
                        }
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["keyboardColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM keyboards WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim();
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["monitorColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM monitors WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim() + " " + dr.GetValue(3).ToString().Trim() + "\"";
                    }
                }

                cell.ToolTipText = info;
            }
            else if (e.ColumnIndex == this.dataGridView.Columns["mouseColumn"].Index)
            {
                DataGridViewCell cell = this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                String info = "";

                MySqlCommand cmd = new MySqlCommand(String.Format(
                                                        "SELECT * FROM mouses WHERE id={0}", cell.Value), conn);

                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        info += dr.GetValue(1).ToString().Trim() + " "
                                + dr.GetValue(2).ToString().Trim();
                    }
                }

                cell.ToolTipText = info;
            }
        }
 private void dgUsuarios_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     dgUsuarios.Rows[e.RowIndex].Cells["editar"].ToolTipText = "Clique aqui para editar";
 }
Esempio n. 31
0
 // Gets image from url
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     LoadImages(e);
 }
Esempio n. 32
0
 // Changes the foreground color of cells in the "Ratings" column 
 // depending on the number of stars. 
 private void dataGridView1_CellFormatting(object sender,
     DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == dataGridView1.Columns["Rating"].Index
         && e.Value != null)
     {
         switch (e.Value.ToString().Length)
         {
             case 1:
                 e.CellStyle.SelectionForeColor = Color.Red;
                 e.CellStyle.ForeColor = Color.Red;
                 break;
             case 2:
                 e.CellStyle.SelectionForeColor = Color.Yellow;
                 e.CellStyle.ForeColor = Color.Yellow;
                 break;
             case 3:
                 e.CellStyle.SelectionForeColor = Color.Green;
                 e.CellStyle.ForeColor = Color.Green;
                 break;
             case 4:
                 e.CellStyle.SelectionForeColor = Color.Blue;
                 e.CellStyle.ForeColor = Color.Blue;
                 break;
         }
     }
 }
Esempio n. 33
0
 private void DataGridViewIsi_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
 }