当前位置: 首页>>代码示例>>C#>>正文


C# DataGridView.Invoke方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridView.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.Invoke方法的具体用法?C# DataGridView.Invoke怎么用?C# DataGridView.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridView的用法示例。


在下文中一共展示了DataGridView.Invoke方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: isRowDisplayed

 public static bool isRowDisplayed(DataGridView varControl, int index)
 {
     bool foo = false;
     if (varControl.InvokeRequired)
     {
         varControl.Invoke((MethodInvoker)delegate
         {
             foo = varControl.Rows[index].Displayed;
         });
         return foo;
     }
     else
     {
         return varControl.Rows[index].Displayed;
     }
 }
开发者ID:PokeAcer549,项目名称:geckowii,代码行数:16,代码来源:watchlist.cs

示例2: BindObjectList

        protected static DataTable BindObjectList(DataGridView dataGridView, IEnumerable list)
        {
            DataTable table = null;

              foreach (var obj in list)
              {
            if (table == null)
            {
              table = CreateObjectFiledTable(obj);
            }

            DataRow row = ConvertObjectToRow(table, obj);

            table.Rows.Add(row);
              }

              if (dataGridView != null)
              {
            dataGridView.Invoke(new Action(() =>
            {
              dataGridView.AutoGenerateColumns = true;
              dataGridView.DataSource = table;
            }));
              }

              return table;
        }
开发者ID:kdxing,项目名称:CTPFutureProvider,代码行数:27,代码来源:ControlHelper.cs

示例3: AddGridItemInvoke

 private void AddGridItemInvoke(DataGridView dataGridView, IPAddressGridItem item)
 {
     if (dataGridView.InvokeRequired)
     {
         dataGridView.Invoke(new AddDataGridViewItemDelegate(AddDataGridViewItem), dataGridView, item);
     }
     else
     {
         AddDataGridViewItem(dataGridView, item);
     }
 }
开发者ID:moonrailgun,项目名称:MRGLanHelper,代码行数:11,代码来源:FrmMain.cs

示例4: DisplayTable

        public void DisplayTable(DataGridView dgrid)
        {
            var provider = dgrid.DataSource as DataTable;
            if (provider.Columns["StopLVL"] == null)
            {
                 provider.Columns.Add(new DataColumn("StopLVL"));
                 provider.Columns.Add(new DataColumn("RevLVL"));
                 provider.Columns.Add(new DataColumn("ZIM"));
                provider.Columns[5].ReadOnly = true;
                provider.Columns[6].ReadOnly = true;
                provider.Columns[7].ReadOnly = true;
            }

            string entrieTrSum = FormatNumber(Math.Round(Strategyperformance.EntireTradesSum, 2));
            string profitTrSum = FormatNumber(Math.Round(Strategyperformance.ProfitTradesSum, 2));
            string losTrSum = FormatNumber(Math.Round(Strategyperformance.LossTradesSum, 2));
            string avgTr = FormatNumber(Math.Round(Strategyperformance.AverageTrade, 2));

            var values = new ArrayList
                             {
                                 Symbol,
                                 MinDt.ToString(DateFormatsManager.CurrentShortDateFormat + " HH:mm:ss"),
                                 MaxDt.ToString(DateFormatsManager.CurrentShortDateFormat + " HH:mm:ss"),
                                 entrieTrSum,
                                 //profitTrSum, //String.Format("{0:0 000.00}",Math.Round(Strategyperformance.ProfitTradesSum, 2)),
                                 //losTrSum, //String.Format("{0:0 000.00}", Math.Round(Strategyperformance.LossTradesSum, 2)),
                                 //Math.Round(Strategyperformance.Profitability, 2),
                                 //Math.Round(Strategyperformance.ProfitFactor, 2),
                                 //avgTr, //String.Format("{0:0 000.00}",Math.Round(Strategyperformance.AverageTrade, 4)),
                                 //Strategyperformance.EntireTradesCount,
                                 //Strategyperformance.ProfitTradesCount,
                                 //Strategyperformance.LossTradesCount,
                                 Strategyperformance.Reversals,
                                 Strategy.AdditionalParameters[7].Value,
                                 Strategy.AdditionalParameters[8].Value,
                                 Strategy.AdditionalParameters[5].Value
                             };

            if (provider != null) provider.Rows.Add(values.ToArray());
            values.Clear();
            try
            {
                MethodInvoker action = delegate
                {
                    dgrid.DataSource = null;
                    dgrid.DataSource = provider;
                    dgrid.Columns[1].FillWeight = dgrid.Columns[2].FillWeight = 180;
                    dgrid.Refresh();
                };
                dgrid.Invoke(action);
            }
            catch (Exception)
            {
            }
        }
开发者ID:rlyalko,项目名称:REVERSALS_v14,代码行数:55,代码来源:SummaryDisplayer.cs

示例5: DisplayQueryData

        private string DisplayQueryData(Connexion.Connexion connexion, string SQL, DataGridView dataGridViewOracleData, BackgroundWorker worker, DoWorkEventArgs eArgs)
        {
            string result = null;
            try
            {
                //string SelectedTable = treeViewOracleSchema.SelectedNode.Text;
                using (DbCommand cmd = connexion.Cnn.CreateCommand())
                {
                    cmd.Transaction = connexion.MyTransaction;
                    int NumRec = 0;
                    try
                    {
                        string SQLCount = "SELECT count(*) " + SQL.Substring(SQL.ToUpper().IndexOf("FROM"));
                        cmd.CommandText = SQLCount; // string.Format("SELECT count(*) FROM {0}", SelectedTable);
                        cmd.Prepare();
                        NumRec = Convert.ToInt32(cmd.ExecuteScalar()) + dataGridViewOracleData.Rows.Count;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        NumRec = 0;
                    }

                    //string SQL = string.Format("SELECT * FROM {0}", SelectedTable);
                    cmd.CommandText = SQL;
                    cmd.Prepare();
                    //int colno = 0;
                    using (DbDataReader rd = cmd.ExecuteReader())
                    {
                        if (ClearData)
                        {
                            if (dataGridViewOracleData.InvokeRequired)
                            {
                                if (!worker.CancellationPending)
                                    dataGridViewOracleData.Invoke(new datagridClear(ClearDataGrid));
                            }
                            else
                            {
                                dataGridViewOracleData.Rows.Clear();
                                dataGridViewOracleData.Columns.Clear();
                            }
                            for (int i = 0; i < rd.FieldCount && !worker.CancellationPending; i++)
                            {
                                if (dataGridViewOracleData.InvokeRequired)
                                {
                                    dataGridViewOracleData.Invoke(new datagridAddCol(AddColDataGrid),
                                                                  new object[] { rd.GetName(i), rd.GetName(i) });
                                }
                                else
                                    dataGridViewOracleData.Columns.Add(rd.GetName(i), rd.GetName(i));
                            }
                        }

                        while (rd.Read() && !worker.CancellationPending)
                        {
                            DataGridViewRow dgrv = new DataGridViewRow();
                            for (int i = 0; i < dataGridViewOracleData.Columns.Count; i++)
                            {
                                dgrv.Cells.Add(new DataGridViewTextBoxCell());
                                dgrv.Cells[i].Value = rd.GetValue(i);
                            }
                            if (dataGridViewOracleData.InvokeRequired)
                            {
                                dataGridViewOracleData.Invoke(new datagridAddRow(AddRowDataGrid), new object[] { dgrv });
                            }
                            else
                                dataGridViewOracleData.Rows.Add(dgrv);

                            int CurrentNumRec = dataGridViewOracleData.Rows.Count;

                            if (worker.WorkerReportsProgress)
                            {
                                if (NumRec != 0)
                                {
                                    int percentComplete = (int)((float)CurrentNumRec / (float)NumRec * 100);
                                    worker.ReportProgress(percentComplete);
                                }
                                else
                                {
                                    worker.ReportProgress(CurrentNumRec % 100);
                                }
                            }
                        }
                        if (worker.WorkerSupportsCancellation)
                        {
                            if (worker.CancellationPending)
                            {
                                eArgs.Cancel = true;
                                result = string.Format("Aborted by user. {0} records found", dataGridViewOracleData.Rows.Count);
                            }
                            else
                            {
                                result = string.Format("{0} records found", dataGridViewOracleData.Rows.Count);
                            }
                        }
                        if (dataGridViewOracleData.InvokeRequired)
                        {
                            dataGridViewOracleData.Invoke(new datagridAutoResizeColumns(DatagridAutoResizeColumns), new object[] { dataGridViewOracleData });
                        }
                        else
//.........这里部分代码省略.........
开发者ID:radtek,项目名称:toaddotnet,代码行数:101,代码来源:DGVQuery.cs

示例6: SetDataGridViewColumnProperty

 void SetDataGridViewColumnProperty(DataGridView dataGridView, string columnName, object value, string propertyName)
 {
     try
     {
         foreach (PropertyInfo property in dataGridView.Columns[columnName].GetType().GetProperties())
         {
             if (property.Name.ToLower() == propertyName.ToLower())
             {
                 dataGridView.Invoke
                 (
                     new MethodInvoker
                     (
                         delegate
                         {
                             property.SetValue(dataGridView.Columns[columnName], value, null);
                         }
                     )
                 );
             }
         }
     }
     catch (Exception ex)
     {
         Tools.Instance.Logger.LogError(ex.ToString());
     }
 }
开发者ID:Riccon,项目名称:remote-desktop,代码行数:26,代码来源:ControlCrossThreading.cs

示例7: refreshgrid

        public static void refreshgrid(DataGridView _dg, BindingSource _bs, bool endstate)
        {

            if (_dg.InvokeRequired)
            {
                try
                {
                    _dg.Invoke(new booldel(refreshgrid), new object[] { _dg,_bs,endstate });
                }
                catch (ObjectDisposedException) { }
            }
            else
            {
                // save screen position and selections
                List<int> sel = new List<int>();
                int first = -1;
                try
                {
                    lock (_dg)
                    {
                        first = _dg.FirstDisplayedScrollingRowIndex;
                        foreach (DataGridViewRow dr in _dg.SelectedRows)
                            sel.Add(dr.Index);
                    }



                    // update screen
                    _bs.RaiseListChangedEvents = true;
                    _bs.ResetBindings(false);
                    // diable updates again
                    _bs.RaiseListChangedEvents = endstate;

                }
                catch (Exception ex)
                {

                }

                // restore screen position and selections
                lock (_dg)
                {
                    try
                    {
                        if (first != -1)
                            _dg.FirstDisplayedScrollingRowIndex = first;
                        foreach (int r in sel)
                            _dg.Rows[r].Selected = true;
                    }
                    catch
                    {
                        // in case this row was deleted in the middle of an update
                    }
                }
            }
        }
开发者ID:antonywu,项目名称:tradelink,代码行数:56,代码来源:SafeBindingSource.cs

示例8: fillAsync

 static public async Task<object> fillAsync(string q, DataTable table, DataGridView view)
 {
     Cursor.Current = Cursors.WaitCursor;
     table.Clear();
     Func<object> query = () =>
     {
         view.Invoke(new fillDelegate(SQLiteUtils.fillInternal), q, table);
         return null;
     };
     await Task.Run(query);
     Cursor.Current = Cursors.Default;
     return null;
 }
开发者ID:cranpun,项目名称:SQLitePrompt,代码行数:13,代码来源:SQLiteUtils.cs

示例9: greedy

        public List<jadwal> greedy(List<jadwal> x, DataTable y, DataGridView LoadLog, DataTable Log)
        {
            DataRow Row;
            bool optim = false;
            int hari = 0;
            int temp_sks = 0;
            int i = 0;
            int limit_loop = 0;
            int[] jam_ngajar = new int[6] { 2, 1, 1, 1, 2, 1 };
            int start_ngajar = 0;
            int problem_count = 0;
            while (!optim)
            {

                    temp_sks = int.Parse(y.Rows[i].ItemArray[2].ToString());
                if (limit_loop < 100)
                {
                    if (x[hari].Limit > temp_sks)
                    {
                        x[hari].Limit -= temp_sks;
                        start_ngajar = jam_ngajar[hari];
                        jam_ngajar[hari] += temp_sks;
                        x[hari].Mengajar.Add(new mengajar() { Guru = y.Rows[i].ItemArray[0].ToString(), MataPelajaran = y.Rows[i].ItemArray[1].ToString(), Sks = temp_sks , Problem=false , StartMengajar = start_ngajar, EndMengajar = jam_ngajar[hari]-1});
                        hari++;
                        i++;
                    }

                    if (!optim && hari > 5)
                    {
                        hari = 0;
                    }
                }
                else
                {
                    int max = 0;
                    while (i < y.Rows.Count)
                    {
                        for (int j = 1; j < x.Count; j++)
                        {
                            if (x[max].Limit < x[j].Limit)
                            {
                                max = j;
                            }
                        }
                        x[max].Limit -= temp_sks;
                        start_ngajar = jam_ngajar[hari];
                        jam_ngajar[hari] += temp_sks - 1;
                        x[max].Mengajar.Add(new mengajar() { Guru = y.Rows[i].ItemArray[0].ToString(), MataPelajaran = y.Rows[i].ItemArray[1].ToString(), Sks = temp_sks , Problem = true, StartMengajar = start_ngajar , EndMengajar = jam_ngajar[hari]});
                        i++;
                        problem_count++;
                    }
                }
                limit_loop++;
                if (i >= y.Rows.Count)
                {
                    optim = true;
                }
            }
            Row = Log.NewRow(); Row["Status"] = "Simple Dispatch"; Row["Keterangan"] = "Lokal Penalti : "+ problem_count;
            Log.Rows.Add(Row);
            LoadLog.Invoke((MethodInvoker)(() => LoadLog.DataSource = Log));
            return x;
        }
开发者ID:yasintahir,项目名称:Project-Skripsi,代码行数:63,代码来源:Dispatch.cs


注:本文中的System.Windows.Forms.DataGridView.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。