程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 更多關於編程 >> C# 實時動態刷新列表[如 DataGridView,ListView等

C# 實時動態刷新列表[如 DataGridView,ListView等

編輯:更多關於編程

       ThreadPool.QueueUserWorkItem(_ =>

      {

      this.Invoke((MethodInvoker)(() =>

      {

      try

      {

      lock (m_objLock5)

      {

      if (EVIs.Count != Evss.Count) return; //出現異常,返回不提取

      foreach (EntityVehicleInfo evi in EVIs)

      {

      int mcuid = evi.MCUID;

      /////////////////////////添加地理位置信息

      EntityVehicleInfo vehicleInfo = null;

      vehicleInfo = DataReader.Instance.HtVehicleInfo[mcuid]asEntityVehicleInfo;

      if (vehicleInfo == null) return;

      int Add_InfoIndex = dgvVehicleInfo.Rows.Add(1);

      DataGridViewRow row = dgvVehicleInfo.Rows[Add_InfoIndex];

      dituHelper.GetAddressByGPS(vehicleInfo.Longitude, vehicleInfo.Latitude, Add_InfoIndex);

      row.Cells["VehicleInfoMCUID"].Value = vehicleInfo.MCUID;

      row.Cells["VEHICLENO"].Value = vehicleInfo.VehicleNo;

      row.Cells["ONLINE"].Value = vehicleInfo.Online;

      row.Cells["ACC"].Value = vehicleInfo.ACC;

      //row.Cells["LONGITUDE"].Value = vehicleInfo.Longitude.ToString("f5");

      //row.Cells["LATITUDE"].Value = vehicleInfo.Latitude.ToString("f5");

      row.Cells["ANGLE"].Value =UtilityHelper.Angle2Direction((int)vehicleInfo.Angle);

      row.Cells["VELOCITY"].Value = vehicleInfo.Velocity;

      row.Cells["LOCATIONSTATE"].Value = vehicleInfo.LocationState;

      row.Cells["RECEIVETIME"].Value = vehicleInfo.ReceiveTime;

      ////////////////////////////添加狀態信息

      EntityVehicleState vehicleState = null;

      vehicleState = DataReader.Instance.HtVehicleState[mcuid]asEntityVehicleState;

      if (vehicleState == null) return;

      int Add_StateIndex = dgvVehicleState.Rows.Add(1);

      DataGridViewRow row2 = dgvVehicleState.Rows[Add_StateIndex];

      row2.Cells["VEHICLENOS"].Value = vehicleInfo.VehicleNo.ToString();

      vehicleInfo = null;

      row2.Cells["PositionTime"].Value = vehicleState.PositionTime.ToString();

      row2.Cells["STOPFUEL"].Value = vehicleState.StopFuel ?"是" : "否";

      row2.Cells["FUELCUT"].Value = vehicleState.FuelCut ? "斷油電" : "通油電";

      row2.Cells["AUTODEFENCE"].Value = vehicleState.AutoFence ?"設防" : "解防";

      row2.Cells["TRUNKBOOT"].Value = vehicleState.TrunkBoot ?"開啟" : "關閉";

      row2.Cells["BRAKING"].Value = vehicleState.Braking ? "剎車踩下" : "剎車松開";

      row2.Cells["DOOROPEN"].Value = vehicleState.DoorOpen ? "打開" : "關閉";

      row2.Cells["ACCON"].Value = vehicleState.ACCOn ? "點火" :"熄火";

      row2.Cells["POWERSAVER"].Value = vehicleState.PowerSaver ?"是" : "否";

      vehicleState = null;

      }

      }

      }

      catch (Exception ex)

      {

      LogHelper.Writeln("Instance_NotifyInfo " + ex.StackTrace);

      }

      }));

      });

      效果如下:

    C# 實時動態刷新列表[如 DataGridView,ListView等 三聯
    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved