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


C# DataGridView.invokeOnThread方法代码示例

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


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

示例1: loadSourceCodeMappings

 public static void loadSourceCodeMappings(DataGridView targetDataGridView)
 {
     targetDataGridView.invokeOnThread(
         () =>
             {
                 targetDataGridView.Columns.Clear();
                 O2Forms.addToDataGridView_Column(targetDataGridView, "replaceThisString", -1);
                 O2Forms.addToDataGridView_Column(targetDataGridView, "withThisString", -1);
                 var scmSourceCodeMappings = getSourceCodeMappings();
                 foreach (SourceCodeMappingsMapping mMapping in scmSourceCodeMappings.Mapping)
                 {
                     O2Forms.addToDataGridView_Row(targetDataGridView, null,
                                                   new object[]
                                                       {mMapping.replaceThisString, mMapping.withThisString});
                 }
             });
 }
开发者ID:pusp,项目名称:o2platform,代码行数:17,代码来源:SourceCodeMappingsUtils.cs

示例2: loadInDataGridView_textSearchResults

        public static void loadInDataGridView_textSearchResults(List<TextSearchResult> currentSearchResults,
                                                                DataGridView dgvTargetDataGridView)
        {
            dgvTargetDataGridView.invokeOnThread(
                () =>
                    {
                        var iMaxRowsToLoad = 500;
                        dgvTargetDataGridView.Columns.Clear();
                        O2Forms.addToDataGridView_Column(dgvTargetDataGridView, "path", 50);
                        O2Forms.addToDataGridView_Column(dgvTargetDataGridView, "file", 50);
                        O2Forms.addToDataGridView_Column(dgvTargetDataGridView, "line #", 50);
                        O2Forms.addToDataGridView_Column(dgvTargetDataGridView, "match text", 100);
                        O2Forms.addToDataGridView_Column(dgvTargetDataGridView, "match line", -1);
                        foreach (TextSearchResult searchResult in currentSearchResults)
                        {
                            O2Forms.addToDataGridView_Row(dgvTargetDataGridView, searchResult,
                                                          new[]
                                                              {
                                                                  Path.GetDirectoryName(searchResult.sFile),
                                                                  Path.GetFileName(searchResult.sFile),
                                                                  searchResult.iLineNumber.ToString(),
                                                                  searchResult.sMatchText,
                                                                  searchResult.sMatchLine.Trim()
                                                              });
                            if (dgvTargetDataGridView.Rows.Count > iMaxRowsToLoad)
                            {
                                DI.log.error("Aborting, MaxRowsToLoad reached: {0}", iMaxRowsToLoad);
                                return;
                            }
                        }

                        // ReSharper disable PossibleNullReferenceException
                        dgvTargetDataGridView.Columns["path"].Width = 20;
                        dgvTargetDataGridView.Columns["line #"].Width = 40;
                        // ReSharper restore PossibleNullReferenceException


                    });

        }
开发者ID:pusp,项目名称:o2platform,代码行数:40,代码来源:SearchUtils.cs

示例3: executeMethodAndOutputResultInTextBoxOrDataGridView

        public void executeMethodAndOutputResultInTextBoxOrDataGridView(MethodInfo mMethod, Object[] aoParams,
                                                                        Object oLiveInstanceOfObject,
                                                                        TextBox tbTextBox_Results,
                                                                        DataGridView dgvDataGridView_Results)
        {
            try
            {
            
            object oInvocationResult = mMethod.Invoke(oLiveInstanceOfObject, aoParams);
            dgvDataGridView_Results.invokeOnThread(
                () =>
                    {
                        try
                        {
                            //Type tMethodTye = mMethod.ReflectedType;

                            //Reflection.invokeMethod_InstanceStaticPublicNonPublic();
                            
                            tbTextBox_Results.Visible = false;
                            if (dgvDataGridView_Results != null)
                                dgvDataGridView_Results.Visible = false;
                            if (null == oInvocationResult)
                            {
                                tbTextBox_Results.Text = String.Format("Info: Method {0} executed sucessfull",
                                                                       mMethod.Name);
                                tbTextBox_Results.Visible = true;
                            }
                            else
                            {
                                switch (oInvocationResult.GetType().FullName)
                                {
                                    case "System.Data.DataTable":
                                        if (dgvDataGridView_Results != null)
                                        {
                                            dgvDataGridView_Results.DataSource = oInvocationResult;
                                            dgvDataGridView_Results.Visible = true;
                                        }

                                        break;
                                    case
                                        "System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
                                        :
                                        var lResults = (List<String>) oInvocationResult;
                                        if (lResults.Count == 0)
                                            String.Format("Info: the List<String> returned had no items");
                                        else
                                        {
                                            tbTextBox_Results.Text = "";
                                            foreach (String sLine in lResults)
                                                tbTextBox_Results.Text += sLine;
                                        }
                                        tbTextBox_Results.Visible = true;

                                        break;
                                    default:
                                        tbTextBox_Results.Text = oInvocationResult.ToString();
                                        tbTextBox_Results.Visible = true;
                                        break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            DI.log.ex(ex,
                                      "Invocaton Error in (GUI thread)executeMethodAndOutputResultInTextBoxOrDataGridView for method: " +
                                      mMethod.Name);
                            tbTextBox_Results.Text = ex.Message;
                            if (ex.InnerException != null)
                            {
                                DI.log.ex(ex, "   InnerException + " + ex.InnerException.Message);
                                tbTextBox_Results.Text += Environment.NewLine + "    InnerException:" +
                                                          ex.InnerException.Message;
                            }
                        }
                    });
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "Invocaton Error in (MTA thread)executeMethodAndOutputResultInTextBoxOrDataGridView for method: " +
                                                      mMethod.Name);
            }
        }
开发者ID:SiGhTfOrbACQ,项目名称:O2.FluentSharp,代码行数:82,代码来源:O2FormsReflectionASCX.cs

示例4: getParameterObjectsFromDataGridColumn

        public Object[] getParameterObjectsFromDataGridColumn(DataGridView dgvDataGridViewWithData,
                                                              String sColumnWithParameters)
        {
            return (object[])dgvDataGridViewWithData.invokeOnThread(
                () =>
                    {
                        var aoParams = new Object[dgvDataGridViewWithData.Rows.Count];
                        try
                        {
                            for (int i = 0; i < dgvDataGridViewWithData.Rows.Count; i++)
                            {
                                Object oParameterTag = dgvDataGridViewWithData.Rows[i].Cells[sColumnWithParameters].Tag;
                                if (null != oParameterTag && ("System.RuntimeType" == oParameterTag.GetType().FullName))
                                {
                                    switch (((Type) oParameterTag).FullName)
                                    {
                                        case "System.Boolean":

                                            aoParams[i] = "true" ==
                                                          (String) dgvDataGridViewWithData.Rows[i].Cells["Value"].Value;
                                            break;
                                        case "System.Int32":
                                            aoParams[i] =
                                                Int32.Parse(
                                                    dgvDataGridViewWithData.Rows[i].Cells["Value"].Value.ToString());
                                            break;
                                        case "System.UInt32":
                                            aoParams[i] =
                                                UInt32.Parse(
                                                    dgvDataGridViewWithData.Rows[i].Cells["Value"].Value.ToString());
                                            break;
                                    }
                                }
                                else
                                    aoParams[i] = dgvDataGridViewWithData.Rows[i].Cells["Value"].Value;
                            }
                        }
                        catch (Exception ex)
                        {
                            DI.log.ex(ex, "in getParameterObjectsFromDataGridColumn: {0}");
                        }
                        return aoParams;
                    });
        }
开发者ID:SiGhTfOrbACQ,项目名称:O2.FluentSharp,代码行数:44,代码来源:O2FormsReflectionASCX.cs


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