Example #1
0
 private void DgvHead_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (DgvHead.Rows[e.RowIndex].Cells[12].Value.ToString() == "ยกเลิก")//สถานะรายงาน
     {
         DgvHead.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
     }
 }
Example #2
0
 /// <summary> 格式化
 /// </summary>
 private void dgvSyncData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value == null || string.IsNullOrEmpty(e.Value.ToString()))
     {
         return;
     }
     string fieldNmae = dgvSyncDataLog.Columns[e.ColumnIndex].DataPropertyName;
     if (fieldNmae.Equals("business_name"))
     {
         DataSources.EnumInterfaceType enumInterfaceType = (DataSources.EnumInterfaceType)Convert.ToInt16(e.Value.ToString());
         e.Value = DataSources.GetDescription(enumInterfaceType, true);
     }
     if (fieldNmae.Equals("external_sys"))
     {
         DataSources.EnumExternalSys enumExternalSys = (DataSources.EnumExternalSys)Convert.ToInt16(e.Value.ToString());
         e.Value = DataSources.GetDescription(enumExternalSys, true);
     }
     if (fieldNmae.Equals("sync_direction"))
     {
         DataSources.EnumSyncDirection enumSyncDirection = (DataSources.EnumSyncDirection)Convert.ToInt16(e.Value.ToString());
         e.Value = DataSources.GetDescription(enumSyncDirection, true);
     }
     if (fieldNmae.Equals("sync_start_time") || fieldNmae.Equals("sync_end_time"))
     {
         long ticks = (long)e.Value;
         e.Value = Common.UtcLongToLocalDateTime(ticks);
     }
 }
Example #3
0
        private void dgvPoints_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            Point p = (Point)dgvPoints.Rows[e.RowIndex].DataBoundItem;

            switch (p.Type)
            {
                case BasicType.ANALOG_STATUS:
                    if (p.ValueAnalog.HasValue)
                        dgvPoints["dgvPoints_colValue", e.RowIndex].Value = p.ValueAnalog.ToString();
                    else
                        dgvPoints["dgvPoints_colValue", e.RowIndex].Value = "Unknown";

                    break;

                case BasicType.DIGITAL_STATUS:
                    if (p.ValueDigital.HasValue)
                        dgvPoints["dgvPoints_colValue", e.RowIndex].Value = p.ValueDigital > 0 ? "ON" : "OFF";
                    else
                        dgvPoints["dgvPoints_colValue", e.RowIndex].Value = "Unknown";

                    break;

                default:

                    break;
            }
        }
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if(  dataGridView1.Columns[e.ColumnIndex].Name == "tgThucTe"
                ||
                dataGridView1.Columns[e.ColumnIndex].Name == "tgDung"){

            if (e.Value != null && e.Value != DBNull.Value)
                e.Value = ((TimeSpan)e.Value).Hours.ToString("00") + ":" +
                           ((TimeSpan)e.Value).Minutes.ToString("00");
                }
            //var hvh = (HistoryNhanVien)dataGridView1.Rows[e.RowIndex].DataBoundItem;
            //if (e.ColumnIndex == 0)
            //{
            //    e.Value = hvh.NhanVien.MaThe;
            //}
            //if (e.ColumnIndex == 1)
            //{
            //    e.Value = hvh.NhanVien.TenNhanVien;
            //}
            //if (e.ColumnIndex == 2) {
            //    e.Value = hvh.IsCheckin ? "Checkin" : "Checkout";
            //}
            //if (e.ColumnIndex == 4) {
            //    e.Value = (hvh.IsCheckin) ? DateTimeUtil.timeToString(hvh.Ca.GioBatDau) : DateTimeUtil.timeToString(hvh.Ca.GioKetThuc);
            //}
            //if (e.ColumnIndex == 5)
            //{
            //    e.Value = DateTimeUtil.timeToString( hvh.ThoiGian.TimeOfDay);
            //}
        }
Example #5
0
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dataGridView1.Rows[e.RowIndex].Cells["saleheadstatusname"].Value.ToString() == "ยกเลิก")
     {
         dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightPink;
     }
 }
Example #6
0
        /// <summary>
        /// Handle the data/image binding in data grid cell
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void LocationDataGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            try
            {
                if (LocationDataGrid.Columns[e.ColumnIndex].Name == "AvailableStatus")
                {
                    if ((this.LocationDataGrid.Rows[e.RowIndex].Cells[7].Value).ToString() == "Available")
                    {
                        e.Value = statusList.Images[0];
                    }
                    else
                    {
                        e.Value = statusList.Images[1];
                    }
                }

                if (LocationDataGrid.Columns[e.ColumnIndex].Name == "img")
                {
                    if ((this.LocationDataGrid.Rows[e.RowIndex].Cells[7].Value).ToString() == "Available")
                    {
                        e.Value = statusList.Images[2];;
                    }
                    else
                    {
                        e.Value = statusList.Images[3];
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.ApplicationName);
            }
        }
 private void dataGridView_CellFormatting( object sender, DataGridViewCellFormattingEventArgs e )
 {
     if( (e.ColumnIndex == Offset.Index) && (e.Value != null) )
     {
         byte b = (byte)e.Value;
         e.Value = b.ToString( "X2" );
         e.FormattingApplied = true;
     }
     else if( e.ColumnIndex == ActionColumn.Index )
     {
         if( (e.RowIndex >= 0) && (e.ColumnIndex >= 0) &&
             (dataGridView[e.ColumnIndex, e.RowIndex] is DataGridViewComboBoxCell) &&
             (dataGridView.Rows[e.RowIndex].DataBoundItem is ActionMenu) )
         {
             ActionMenu menu = dataGridView.Rows[e.RowIndex].DataBoundItem as ActionMenu;
             if( menu.Default != null )
             {
                 ActionMenuEntry a = menu.Default.MenuAction;
                 if( a != (e.Value as ActionMenuEntry) )
                 {
                     e.CellStyle.BackColor = Color.Blue;
                     e.CellStyle.ForeColor = Color.White;
                 }
             }
         }
     }
 }
Example #8
0
 private void dgpreview_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.RowIndex > -1 && e.ColumnIndex > -1 && dgpreview.SelectedCells.Count > 0)
     {
         string n = dgpreview.Columns[e.ColumnIndex].Name;
         if (dgpreview.Rows[e.RowIndex].DataBoundItem != null)
         {
             if (n == "ActionInfo" && App.CurrentConfig.SteamIntegrationActivated)
             {
                 GamePreview gp = (GamePreview)dgpreview.Rows[e.RowIndex].DataBoundItem;
                 string t = "";
                 string k = Functions.Translation("keys");
                 if (gp.TargetGame.Keys.Count == 1) k = "key";
                 else if (gp.TargetGame.Keys.Count == 0) k = Functions.Translation("no key");
                 string keys = k;
                 if (gp.TargetGame.Keys.Count > 0) keys = gp.TargetGame.Keys.Count.ToString("N0") + " " + k;
                 switch (gp.Action)
                 {
                     case GamePreview.ImportAction.CreateANewGame:
                         t = string.Format(Functions.Translation("Create a new game and add {0}"), keys);
                         break;
                     case GamePreview.ImportAction.ImportKeysInExistingGame:
                         t = Functions.Translation("Import in a existing game");
                         break;
                     case GamePreview.ImportAction.UserActionRequired:
                         t = Functions.Translation("Not importable, please import this line manually");
                         break;
                 }
                 if (gp.ActionInfo.Length > 0) t += " (" + gp.ActionInfo + ")";
                 e.Value = t;
             }
         }
     }
 }
Example #9
0
 private void AmountCellFormating(DataGridView grd, DataGridViewCellFormattingEventArgs e)
 {
     if (grd.Columns[e.ColumnIndex].Name.Equals("Amount"))
     {
         e.Value = string.Format("CHF {0}.-", e.Value);
     }
 }
Example #10
0
        private void dtLista_CellFormatting(object sender,
                                            System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (this.dtLista.Columns[e.ColumnIndex].Name.Equals("IVA"))
            {
                dtLista.Columns[e.ColumnIndex].Width = 35;
            }


            if (e.ColumnIndex == 0)
            {
                dtLista.Columns[e.ColumnIndex].Visible = false;
            }


            if (e.ColumnIndex == 1)
            {
                dtLista.Columns[e.ColumnIndex].Width = 75;
            }



            // Set the background to red for negative values in the Balance column.
            if (dtLista.Columns[e.ColumnIndex].Name.Equals("Stock"))
            {
                if (Convert.ToInt32(e.Value) <= addProducto.getCantidadMinima())
                {
                    e.CellStyle.BackColor = Color.DarkOrange;
                }
            }
        }
Example #11
0
 private void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     Vehicle vehicle = dataGridView.Rows[e.RowIndex].DataBoundItem as Vehicle;
         try
         {
             if (dataGridView.Columns[e.ColumnIndex].Name == "OriginId")
             {
                 e.Value = vehicle.OriginCustomer.Id;
             }
             else if (dataGridView.Columns[e.ColumnIndex].Name == "OriginName")
             {
                 e.Value = vehicle.OriginCustomer.Name;
             }
             else if (dataGridView.Columns[e.ColumnIndex].Name == "CurrentId")
             {
                 e.Value = vehicle.CurrentCustomer.Id;
             }
             else if (dataGridView.Columns[e.ColumnIndex].Name == "CurrentName")
             {
                 e.Value = vehicle.CurrentCustomer.Name;
             }
             else if (dataGridView.Columns[e.ColumnIndex].Name == "VehicleType")
             {
                 e.Value = vehicle.Vehicletype.Name;
             }
         }
         catch
         {
             MessageUtil.ShowTips("错误" + vehicle.Serial);
         }
 }
Example #12
0
        private void ChangesViewCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (changesView.Columns["img"] == null)
            {
                return;
            }

            if ((e.ColumnIndex == changesView.Columns["img"].Index) && (e.Value != null))
            {
                DataGridViewCell cell =
                    changesView.Rows[e.RowIndex].Cells[e.ColumnIndex];
                DataGridViewCell valueCell =
                    changesView.Rows[e.RowIndex].Cells["EventType"];
                var eventType = (int)valueCell.Value;

                switch (eventType)
                {
                    case 1:
                        cell.ToolTipText = "Добавлена пара";
                        break;
                    case 2:
                        cell.ToolTipText = "Отменена пара";
                        break;
                    case 3:
                        cell.ToolTipText = "Изменена аудитория";
                        break;
                    default:
                        cell.ToolTipText = "Страх и ужас";
                        break;

                }
            }
        }
Example #13
0
        private void dtLista_CellFormatting(object sender,
                                            System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            //if (this.dtLista.Columns[e.ColumnIndex].Name.Equals("IVA"))
            //{

            //    dtLista.Columns[e.ColumnIndex].Width = 35;
            //}


            //try
            //{
            //    if (this.dtLista.Columns[e.ColumnIndex].Name.Equals("Codigo"))
            //    {

            //        dtLista.Columns[e.ColumnIndex].Visible = false;
            //    }
            //}
            //catch { }


            // Set the background to red for negative values in the Balance column.
            if (dtLista.Columns[e.ColumnIndex].Name.Equals("Stock"))
            {
                //if (Convert.ToInt32(e.Value) <= addPedido.getCantidadMinima())
                //{
                //    e.CellStyle.BackColor = Color.DarkOrange;

                //}
            }
        }
Example #14
0
        private void cellFormatter(object sender,
                                   System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            string colName = alarmList.Columns[e.ColumnIndex].Name;

            if (colName.Equals("ColumnID"))
            {
                if (e.Value is Int32)
                {
                    int id = (int)e.Value;
                    if (id < 0)
                    {
                        e.Value = "-";
                    }
                }
            }
            else if (colName.Equals("ColumnSilent"))
            {
                if (e.Value is AlarmDefinition.Option)
                {
                    e.Value = (((AlarmDefinition.Option)e.Value) & AlarmDefinition.Option.Silent) != 0;
                }
            }
            else if (colName.Equals("ColumnAutoAck"))
            {
                if (e.Value is AlarmDefinition.Option)
                {
                    e.Value = (((AlarmDefinition.Option)e.Value) & AlarmDefinition.Option.AutoAck) != 0;
                }
            }
        }
Example #15
0
 private void gridFiles_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     var row = gridFiles.Rows[e.RowIndex];
     var file = (StatusFileForGrid) row.DataBoundItem;
     e.CellStyle.BackColor = GetGridFilesLocalColor(file.Type);
     e.CellStyle.SelectionBackColor = e.CellStyle.BackColor;
 }
Example #16
0
        private void dgvResult_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                if (e.Value == DBNull.Value)    //if DBNull
                {
                    e.CellStyle.BackColor = Color.WhiteSmoke;
                }
                else
                {
                    string temp         = e.Value.ToString();
                    double dblCellValue = Convert.ToDouble(temp.Substring(0, temp.Length - 2));

                    temp = dgvResult.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString();
                    double dblLowLimit = Convert.ToDouble(temp.Substring(0, temp.Length - 2));

                    temp = dgvResult.Rows[e.RowIndex].Cells[e.ColumnIndex + 2].Value.ToString();
                    double dblHighLimit = Convert.ToDouble(temp.Substring(0, temp.Length - 2));

                    if (dblCellValue < dblLowLimit || dblCellValue > dblHighLimit)
                    {
                        //e.CellStyle.BackColor = Color.Red;
                        dgvResult.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
                    }
                    else
                    {
                        dgvResult.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green;
                    }
                }// end of if DBNull
            }
        }
Example #17
0
 /// <summary> 格式化
 /// </summary>
 private void dgvBakList_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value == null)
     {
         return;
     }
     try
     {
         string fieldNmae = dgvBakList.Columns[e.ColumnIndex].DataPropertyName;
         if (fieldNmae.Equals("bak_time"))
         {
             long ticks = (long)e.Value;
             e.Value = Common.UtcLongToLocalDateTime(ticks);
         }
         if (fieldNmae.Equals("bak_method"))
         {
             DataSources.EnumBackupMethod enumStatus = (DataSources.EnumBackupMethod)Convert.ToInt16(e.Value.ToString());
             e.Value = DataSources.GetDescription(enumStatus, true);
         }
         if (fieldNmae.Equals("is_Success"))
         {
             DataSources.EnumYesNo enumStatus = (DataSources.EnumYesNo)Convert.ToInt16(e.Value.ToString());
             e.Value = DataSources.GetDescription(enumStatus, true);
         }
     }
     catch (Exception ex)
     {
         Utility.Log.Log.writeLineToLog(ex.Message, "选择器-备份记录列表格式化失败");
     }
 }
Example #18
0
        private void dgvBirthdays_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            if (cbxChooseDisplay.SelectedIndex == 1)
            {
                if (dgv.Columns[e.ColumnIndex].Name == "name" && e.RowIndex >= 0 && dgv["name", e.RowIndex].Value is string)
                {
                    string modname;
                    string n = e.Value.ToString();

                    int spacepos = n.LastIndexOf(" ");
                    int dashpos = n.LastIndexOf("-");

                    if(dashpos > spacepos)
                    {
                        modname = n.Remove(0, dashpos + 1);
                        modname = modname.Insert(0, "The ");
                    }
                    else
                    {
                        modname = n.Remove(0, spacepos);
                        modname = modname.Insert(0, "The");
                    }

                    modname = modname.Insert(modname.Length, "'s");
                    e.Value = modname;
                }
            }
        }
        public void grdBase_onCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            object grd = sender;
            object val = e.Value;
            if (e.ColumnIndex == 4 || e.ColumnIndex == 6 || e.ColumnIndex == 7)
            {
                e.CellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
            }
            else
            {
                e.CellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
            }

            if (e.ColumnIndex == 2)
            {
                e.CellStyle.WrapMode = DataGridViewTriState.True;
            }

            if (e.ColumnIndex == 4 || e.ColumnIndex == 6 || e.ColumnIndex == 7)
            {
                e.CellStyle.Format = FormatString.FormatDate;

            }

        }
 private void DataGridView1OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex].DataPropertyName.Contains("."))
         e.Value = BindingExtensions.GetValueFromPath(
             dataGridView1.Rows[e.RowIndex].DataBoundItem,
             dataGridView1.Columns[e.ColumnIndex].DataPropertyName);
 }
        void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {

            }
        }
 private void dataGridView_selectedCourses_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dataGridView_selectedCourses.Columns[e.ColumnIndex].HeaderText == "上课时间")
     {
         e.Value = Utils.DecodeTime(e.Value.ToString());
     }
 }
Example #23
0
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         dataGridView1.Rows[e.RowIndex].HeaderCell.Value = Convert.ToString(e.RowIndex + 1);
     }
 }
Example #24
0
 private void DgvPODetail_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (DgvPODetail.Rows[e.RowIndex].Cells[0].Value.ToString() == "0000000000-00")
     {
         DgvPODetail.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.FromArgb(147, 4, 140);
     }
 }
Example #25
0
 private void hostsDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     hostsDataGridView[e.ColumnIndex, e.RowIndex].Style.BackColor =
         HostManager.IsEnabled(hostsDataGridView[HostManager.EnabledColumnNumber, e.RowIndex].Value.ToString())
             ? Color.LightGreen
             : Color.LightGray;
 }
        public void grdBase_onCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            object grd = sender;
            object val = e.Value;
            e.CellStyle.WrapMode = DataGridViewTriState.True;

            Type dataType = val.GetType();

            if (e.ColumnIndex == 2)
            {
                e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
            else
            {
                if (typeof(int) == dataType || typeof(decimal) == dataType || typeof(float) == dataType || typeof(long) == dataType || typeof(double) == dataType)
                {
                    e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }
                else if (typeof(DateTime) == dataType)
                {
                    e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    e.CellStyle.Format = FormatString.FormatDate;
                }
                else
                {
                    e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
                }
            }
        }
 private void dgvJuridicPersons_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dgvJuridicPersons.Columns[e.ColumnIndex].Name == "ColumnJuridicPersonAccountId")
     {
         e.Value = (e.Value as AccountDTO).Code;
     }
 }
        void DgSalesOrdersCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            SalesOrderLine salesOrderLine = (SalesOrderLine)DgSalesOrders.Rows[e.RowIndex].DataBoundItem;

            switch (DgSalesOrders.Columns[e.ColumnIndex].DataPropertyName) {

                case "customer" :
                    e.Value = salesOrderLine.SalesOrder.Customer.name;
                    break;

                case "salesOrderDate" :
                    e.Value = string.Format( "{0:dd/MM/yyyy}", salesOrderLine.SalesOrder.salesOrderDate);
                    break;

                case "product" :
                    e.Value = salesOrderLine.Product.description;
                    break;

                case "status" :
                    e.Value = salesOrderLine.SalesOrderStatus.description;
                    e.CellStyle.BackColor = GetStatusColor(salesOrderLine.SalesOrderStatus);
                    break;

            }
        }
 private void dgv_Buscar_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value != null)
     {
         e.Value = e.Value.ToString().ToUpper();
         e.FormattingApplied = true;
     }
 }
Example #30
0
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     foreach (DataGridViewRow row in dataGridView1.Rows)
     {
         if (((FormattedLogMessage)row.DataBoundItem).MessageColor!=System.Drawing.Color.Transparent)
             row.DefaultCellStyle.BackColor = ((FormattedLogMessage)row.DataBoundItem).MessageColor;
     }
 }
Example #31
0
 private void allOperationDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value is decimal)
     {
         if (Convert.ToDecimal(e.Value) == 0M)
             e.Value = null;
     }
 }
Example #32
0
 private void pRODUTODataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     DataGridView tabela = sender as DataGridView;
     if (tabela.Columns[e.ColumnIndex].Name.Equals("colunaPreco")) {
         string valor = ((double)e.Value).ToString("0.00");
         e.Value = valor;
     }
 }
Example #33
0
 private void dgvCrequest_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == 2) {
         if (dgvCrequest.Rows[e.RowIndex].Cells["cStatusId"].Value.ToString() == "1") { // ยกเลิก
             dgvCrequest.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
         }
     }
 }
Example #34
0
 private void outstationChannelMappingsDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == dataGridViewTextBoxColumn5.Index && (e.Value == null || e.Value.Equals("")))
     {
         e.Value = "Unknown";
         e.FormattingApplied = true;
     }
 }
Example #35
0
 private void dgvUser_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dgvUser.Columns[e.ColumnIndex].Name == "PassDataGridViewTextBoxColumn" && e.Value != null)
     {
         dgvUser.Rows[e.RowIndex].Tag = e.Value;
         e.Value = new String('*', e.Value.ToString().Length);
     }
 }
Example #36
0
        void steps_DataGridView_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (steps_DataGridView.Columns[e.ColumnIndex].Name.Equals("log"))
            {
                if (e.Value != null)
                {
                    Step thisStep = steps_DataGridView.Rows[e.RowIndex].DataBoundItem as Step;
                    if (thisStep.Status == eStatus.COMPLETED || thisStep.Status == eStatus.FAILED)
                    {
                        string fullLogPath = e.Value.ToString();
                        e.Value = Path.GetFileName(fullLogPath);
                        DataGridViewCell thisCell = steps_DataGridView[e.ColumnIndex, e.RowIndex];
                        thisCell.ToolTipText = fullLogPath;
                    }
                    else
                    {
                        e.Value = "";
                    }
                }
            }
            if (steps_DataGridView.Columns[e.ColumnIndex].Name.Equals("status"))
            {
                Step             thisStep = steps_DataGridView.Rows[e.RowIndex].DataBoundItem as Step;
                DataGridViewCell thisCell = steps_DataGridView[e.ColumnIndex, e.RowIndex];
                if (thisStep.Status == eStatus.READY)
                {
                    e.Value = "";
                    thisCell.Style.ForeColor = Color.Black;
                }
                else if (thisStep.Status == eStatus.COMPLETED)
                {
                    e.Value = "Completed";
                    thisCell.Style.ForeColor = Color.ForestGreen;
                    DataGridViewRow thisRow = steps_DataGridView.Rows[e.RowIndex];
                    thisRow.DefaultCellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Regular);
                }
                else if (thisStep.Status == eStatus.FAILED)
                {
                    e.Value = "Failed";
                    thisCell.Style.ForeColor = Color.Red;

                    DataGridViewRow thisRow = steps_DataGridView.Rows[e.RowIndex];
                    thisRow.DefaultCellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
                }
                else if (thisStep.Status == eStatus.SKIPPED)
                {
                    e.Value = "Skipped";
                    thisCell.Style.ForeColor = Color.DarkGray;
                }
                else if (thisStep.Status == eStatus.STARTED)
                {
                    e.Value = "In Progress";
                    thisCell.Style.ForeColor = Color.Orange;
                    DataGridViewRow thisRow = steps_DataGridView.Rows[e.RowIndex];
                    thisRow.DefaultCellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
                }
            }
        }
Example #37
0
 // Changes how cells are displayed depending on their columns and values.
 private void dataGridView1_CellFormatting(object sender,
                                           System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     // Set the background to red for negative values in the Balance column.
     if (e.RowIndex > -1 && Convert.ToBoolean(pilotsList_dataGridView1[11, e.RowIndex].Value))
     {
         pilotsList_dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(255, 255, 198, 198);
     }
 }
Example #38
0
 /// <summary>
 /// 格式化日期列
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataGridViewX1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == DataGridViewX1.Columns["创建时间"].Index)   //格式化日期
     {
         if (e.Value != null)
         {
             e.Value = Convert.ToDateTime(e.Value).ToString("yyyy-MM-dd");
         }
     }
 }
Example #39
0
 private void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value != null && dataGridView1.Columns[e.ColumnIndex].Name.Equals("planeNameDataGridViewTextBoxColumn"))
     {
         if (e.Value.ToString().Contains('a'))
         {
             e.CellStyle.ForeColor = Color.Green;
         }
     }
 }
 void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     switch (e.ColumnIndex)
     {
     case 1:                     // TokenID
     case 2:                     // Secret
     case 4:                     // PrivateID
         e.Value = encoder((byte[])e.Value);
         break;
     }
 }
Example #41
0
    //</Snippet050>

    // 2 of 2 for How to: Display Images in Cells of the Windows Forms DataGridView Control
    //<Snippet055>
    private void dataGridView1_CellFormatting(object sender,
                                              System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
    {
        if (dataGridView1.Columns[e.ColumnIndex].Name == "Icon")
        {
            if (e.RowIndex % 5 == 0)
            {
                Bitmap bmp = new Bitmap(this.GetType(), "Bitmap2.bmp");
                e.Value = bmp;
            }
        }
    }
Example #42
0
        public void cell_formatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            lock (SCMClient._help_list_sync)
            {
                try
                {
                    dataGridView.ClearSelection();
                    foreach (DataGridViewRow row in dataGridView.Rows)
                    {
                        var r = row.DataBoundItem as Record;
                        if (r.APInteracted)
                        {
                            row.DefaultCellStyle.BackColor = Color.Green;
                            row.DefaultCellStyle.ForeColor = Color.White;
                        }
                    }

                    if (dataGridView.Columns[e.ColumnIndex].Name.Equals("NeedsHelp"))
                    {
                        if (e.Value.Equals(false))
                        {
                            CurrencyManager cm = (CurrencyManager)dataGridView.BindingContext[dataGridView.DataSource];


                            this.BeginInvoke(new MethodInvoker(() =>
                            {
                                cm.SuspendBinding();
                                dataGridView.Rows[e.RowIndex].Visible = false;
                                //RemoveRecord(dataGridView.Rows[e.RowIndex].DataBoundItem as Record);
                                cm.ResumeBinding();
                            }));
                        }
                        else
                        {
                            CurrencyManager cm = (CurrencyManager)dataGridView.BindingContext[dataGridView.DataSource];


                            this.BeginInvoke(new MethodInvoker(() =>
                            {
                                cm.SuspendBinding();
                                dataGridView.Rows[e.RowIndex].Visible = true;
                                //RemoveRecord(dataGridView.Rows[e.RowIndex].DataBoundItem as Record);
                                cm.ResumeBinding();
                            }));
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("Cell Formatting ERROR");
                }
            }
        }
Example #43
0
        private void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (this.dataGridView1.Columns[e.ColumnIndex].Name.Equals("POS"))
            //if a column in the POS table is select, higlight the token cell as well
            {
                int ri = e.RowIndex;

                if (dataGridView1[1, ri].Selected == true)
                {
                    dataGridView1[0, ri].Style.BackColor = Color.LightGray;
                }
            }
        }
Example #44
0
 private void dg_data_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     // Set the background to red for negative values in the Balance column.
     if (dg_data.Columns[e.ColumnIndex].Name.Equals("clm_qty"))
     {
         Int32 intValue;
         if (Int32.TryParse((String)e.Value, out intValue) && (intValue < 10))
         {
             e.CellStyle.BackColor          = Color.Red;
             e.CellStyle.SelectionBackColor = Color.DarkRed;
         }
     }
 }
Example #45
0
 protected override void OnCellFormatting(System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     base.OnCellFormatting(e);
     if ((e.CellStyle.FormatProvider is System.ICustomFormatter))
     {
         System.ICustomFormatter icustomFormatter = e.CellStyle.FormatProvider.GetFormat(typeof(System.ICustomFormatter)) as System.ICustomFormatter;
         if (icustomFormatter != null)
         {
             e.Value             = icustomFormatter.Format(e.CellStyle.Format, e.Value, e.CellStyle.FormatProvider);
             e.FormattingApplied = true;
         }
     }
 }
Example #46
0
    //</Snippet10>

    //<Snippet20>
    // Changes how cells are displayed depending on their columns and values.
    private void dataGridView1_CellFormatting(object sender,
                                              System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
    {
        //<Snippet21>
        // Set the background to red for negative values in the Balance column.
        if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Balance"))
        {
            Int32 intValue;
            if (Int32.TryParse((String)e.Value, out intValue) &&
                (intValue < 0))
            {
                e.CellStyle.BackColor          = Color.Red;
                e.CellStyle.SelectionBackColor = Color.DarkRed;
            }
        }
        //</Snippet21>

        //<Snippet22>
        // Replace string values in the Priority column with images.
        if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Priority"))
        {
            // Ensure that the value is a string.
            String stringValue = e.Value as string;
            if (stringValue == null)
            {
                return;
            }

            // Set the cell ToolTip to the text value.
            DataGridViewCell cell = dataGridView1[e.ColumnIndex, e.RowIndex];
            cell.ToolTipText = stringValue;

            // Replace the string value with the image value.
            switch (stringValue)
            {
            case "high":
                e.Value = highPriImage;
                break;

            case "medium":
                e.Value = mediumPriImage;
                break;

            case "low":
                e.Value = lowPriImage;
                break;
            }
        }
        //</Snippet22>
    }
Example #47
0
 //code untuk formatiing data di gridview
 private void dgvPriceCategory_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (dgvPriceCategory.Columns[e.ColumnIndex].Name.Equals("Status"))
     {
         if (e.Value != null & e.Value.ToString() == "0")
         {
             e.Value = "Deactive";
         }
         else if (e.Value != null & e.Value.ToString() == "1")
         {
             e.Value = "Active";
         }
     }
 }
Example #48
0
 public void clinetGridView_CellFromatting(Object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == 7)
     {
         if (e.Value.ToString() == "ture")
         {
             e.Value = "女";
         }
         else
         {
             e.Value = "男";
         }
     }
 }
Example #49
0
        private void dataGridViewDetail_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            DataGridViewRow       row   = dataGridViewDetail.Rows[e.RowIndex];
            CostumeRetailAnalysis order = (CostumeRetailAnalysis)row.DataBoundItem;

            if (InboundDays.Index == e.ColumnIndex)
            {
                e.Value = order.InboundDays;
            }
            else if (UnmovedDays.Index == e.ColumnIndex)
            {
                e.Value = order.UnmovedDays;
            }
        }
 private void ProductsDataGridView_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e.ColumnIndex == DataGridView1.Columns(3).Index&& e.Value != null)
     {
         //
         if (Convert.ToInt32(e.Value) < 10)
         {
             e.CellStyle.BackColor = Color.OrangeRed;
             e.CellStyle.ForeColor = Color.LightGoldenrodYellow;
         }
         //
     }
     //
 }
Example #51
0
        private void dtLista_CellFormatting(object sender,
                                            System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (dtLista.Rows.Count > 0)
            {
                if (e.ColumnIndex > 11)
                {
                    dtLista.Columns[e.ColumnIndex].Visible = false;
                }

                if (dtLista.Columns[e.ColumnIndex].Name.Equals("Compra") ||
                    dtLista.Columns[e.ColumnIndex].Name.Equals("Venta") ||
                    dtLista.Columns[e.ColumnIndex].Name.Equals("VentaConIVA"))
                {
                    //   dtLista.Columns["Compra"].Width = 110;
                    //  dtLista.Columns["Venta"].Width = 110;
                    System.Windows.Forms.DataGridViewCellStyle dataCurrency = new System.Windows.Forms.DataGridViewCellStyle();

                    dataCurrency.Format    = "C4";
                    dataCurrency.NullValue = "0.0";
                    dtLista.Columns["Compra"].DefaultCellStyle      = dataCurrency;
                    dtLista.Columns["Venta"].DefaultCellStyle       = dataCurrency;
                    dtLista.Columns["VentaConIVA"].DefaultCellStyle = dataCurrency;
                }

                // Set the background to red for negative values in the Balance column.
                if (dtLista.Columns[e.ColumnIndex].Name.Equals("Stock"))
                {
                    // dtLista.Columns[e.ColumnIndex].Width = 70;
                    if (Convert.ToInt32(e.Value) <= addProducto.getCantidadMinima())
                    {
                        e.CellStyle.BackColor = Color.DarkOrange;
                        e.CellStyle.Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.75F, System.Drawing.FontStyle.Bold);
                        e.CellStyle.BackColor = Color.DarkOrange;
                        e.CellStyle.ForeColor = Color.Red;
                    }
                }

                //if (this.dtLista.Columns[e.ColumnIndex].Name.Equals("Codigo"))
                //{

                //    dtLista.Columns[e.ColumnIndex].Width = -1;

                //}
            }
        }
Example #52
0
        protected void grid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            try
            {
                this.SuspendLayout();

                if (e.RowIndex >= 0)
                {
                    IBaseEntity rowToDraw = (IBaseEntity)((DataGridView)sender).Rows[e.RowIndex].DataBoundItem;
                    if (rowToDraw != null)
                    {
                        if (rowToDraw.deletedDate != null)
                        {
                            e.CellStyle.BackColor = Color.LightCoral;
                        }
                        Font oFont;
                        switch (rowToDraw.CurrentState)
                        {
                        case ObjectState.delete:
                            oFont            = new Font(e.CellStyle.Font.Name, e.CellStyle.Font.Size, FontStyle.Strikeout);
                            e.CellStyle.Font = oFont;
                            break;

                        case ObjectState.edit:
                            e.CellStyle.BackColor = Color.Yellow;
                            break;

                        case ObjectState.insert:
                            e.CellStyle.BackColor = Color.LightGreen;
                            break;

                        default:
                            oFont            = new Font(e.CellStyle.Font.Name, e.CellStyle.Font.Size, FontStyle.Regular);
                            e.CellStyle.Font = oFont;
                            break;
                        }
                    }
                }
                this.ResumeLayout();
            }
            catch (Exception ex)
            {
                Display.ShowError(ex.Message);
            }
        }
Example #53
0
        /// <summary>
        /// Handles the CellFormatting event of the dgrdDisplayStaffInfo control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewCellFormattingEventArgs"/> instance containing the event data.</param>
        private void dgrdDisplayStaffInfo_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (e == null || e.Value == null || !(sender is DataGridView))
            {
                return;
            }
            DataGridView view1          = (DataGridView)sender;
            object       originalValue1 = e.Value;

            if (view1.Columns[e.ColumnIndex].DataPropertyName == "Married")
            {
                if (originalValue1.ToString() == "No" || originalValue1.ToString() == "False")
                {
                    e.Value = "No";
                }
                else
                {
                    e.Value = "Yes";
                }

                if (e == null || e.Value == null || !(sender is DataGridView))
                {
                    return;
                }
            }

            DataGridView view          = (DataGridView)sender;
            object       originalValue = e.Value;

            if (view.Columns[e.ColumnIndex].DataPropertyName == "Gender")
            {
                if (originalValue.ToString() == "0" || originalValue.ToString() == "Female")
                {
                    e.Value = "Female";
                }
                else if (originalValue.ToString() == "1" || originalValue.ToString() == "Male")
                {
                    e.Value = "Male";
                }
                else
                {
                    e.Value = string.Empty;
                }
            }
        }
Example #54
0
 private void dgvStoreList_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (dgvStoreList.Columns[e.ColumnIndex].Name.Equals("Status"))
     {
         if (e.Value != null & e.Value.ToString() == "0")
         {
             e.Value = "Closed";
         }
         else if (e.Value != null & e.Value.ToString() == "1")
         {
             e.Value = "Open";
         }
         else if (e.Value != null & e.Value.ToString() == "2")
         {
             e.Value = "Renovation";
         }
     }
 }
Example #55
0
 private void dtLista_CellFormatting(object sender,
                                     System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     try
     {
         if (dtLista.Columns[e.ColumnIndex].Name.Equals("Estado"))
         {
             if ((e.Value.ToString()).Contains("COTIZACION"))
             {
                 e.CellStyle.BackColor = Color.OrangeRed;
             }
         }
     }
     catch (Exception ex)
     {
         Datos.Excepciones.Gestionar(ex);
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #56
0
        private void dtLista_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            NProducto getProducto = new NProducto();

            if (dtLista.Columns[e.ColumnIndex].Name.Equals("Stock"))
            {
                // dtLista.Columns[e.ColumnIndex].Width = 70;
                if (Convert.ToInt32(e.Value) <= getProducto.getCantidadMinima())
                {
                    e.CellStyle.Font      = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Bold);
                    e.CellStyle.BackColor = Color.DarkOrange;
                    e.CellStyle.ForeColor = Color.Red;
                }
            }
            if (dtLista.Columns[e.ColumnIndex].Name.Equals("Marca"))
            {
                e.CellStyle.Font      = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Bold);
                e.CellStyle.ForeColor = Color.Black;
            }
        }
Example #57
0
        private void dtgDSPhieuThue_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
        {
            if (dtgDSPhieuThue.Columns[e.ColumnIndex].Name.Equals("TinhTrang"))
            {
                int?tinhTrang = e.Value as int?;

                // replace statement checks with your own conditions
                if (tinhTrang == 0)
                {
                    e.Value = "Đang thuê";
                }
                else if (tinhTrang == 1)
                {
                    e.Value = "Đã trả phòng";
                }
                else
                {
                    e.Value = "Đã thanh toán";
                }
            }
        }
Example #58
0
 /// <summary>
 /// 表格里面的单元格点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void songsDataGridView_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e != null)
     {
         if (this.songsDataGridView.Columns[e.ColumnIndex].Name == "Date")
         {
             if (e.Value != null)
             {
                 try
                 {
                     e.Value             = DateTime.Parse(e.Value.ToString()).ToLongDateString();
                     e.FormattingApplied = true;
                 }
                 catch (FormatException)
                 {
                     Console.WriteLine("{0} is not a valid date.", e.Value.ToString());
                 }
             }
         }
     }
 }
Example #59
0
 private void clientsDataGridView_CellFormatting(object sender,
                                                 System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
 {
     if (e != null)
     {
         /*if (this.clientsDataGridView.Columns[e.ColumnIndex].Name == "Release Date")
          * {
          *  if (e.Value != null)
          *  {
          *      try
          *      {
          *          e.Value = DateTime.Parse(e.Value.ToString())
          *              .ToLongDateString();
          *          e.FormattingApplied = true;
          *      }
          *      catch (FormatException)
          *      {
          *          Console.WriteLine("{0} is not a valid date.", e.Value.ToString());
          *      }
          *  }
          * }*/
     }
 }
Example #60
0
 public FormattingArgs(swf.DataGridViewCellFormattingEventArgs args, GridColumn column, object item, int row)
     : base(column, item, row)
 {
     this.Args = args;
 }