小编Lui*_*cio的帖子

在使用foreach迭代时如何知道行索引?

在下一个示例中,我如何知道当前行索引?

foreach (DataRow temprow in temptable.Rows)
{
//this.text = temprow.INDEX????
}
Run Code Online (Sandbox Code Playgroud)

c# foreach

8
推荐指数
5
解决办法
6万
查看次数

8
推荐指数
1
解决办法
4589
查看次数

构建向导的好模式?

我通常使用a TabControl并以某种方式隐藏选项卡并浏览它们.

我很好奇其他方法这样做!

c# wizard winforms

7
推荐指数
1
解决办法
2299
查看次数

为什么LINQ to Entities不识别某些方法?

为什么我不能这样做:

usuariosEntities usersDB = new usuariosEntities();      
foreach (DataGridViewRow user in dgvUsuarios.Rows)
{
   var rowtoupdate = 
       usersDB.usuarios.Where(
       u => u.codigo_usuario == Convert.ToInt32(user.Cells[0].Value)
       ).First();
   rowtoupdate.password = user.Cells[3].Value.ToString();
}
usersDB.SaveChanges();
Run Code Online (Sandbox Code Playgroud)

并且必须这样做:

usuariosEntities usersDB = new usuariosEntities();      
foreach (DataGridViewRow user in dgvUsuarios.Rows)
{
   int usercode = Convert.ToInt32(user.Cells[0].Value);
   var rowtoupdate = 
       usersDB.usuarios.Where(u => u.codigo_usuario == usercode).First();
   rowtoupdate.password = user.Cells[3].Value.ToString();
}
usersDB.SaveChanges();
Run Code Online (Sandbox Code Playgroud)

我必须承认它是一个更易读的代码,但为什么不能这样做呢?

c# linq-to-entities winforms

6
推荐指数
1
解决办法
3800
查看次数

如何从包含任何容器中的控件的表单中获取所有控件?

例如,我需要一种方法来禁用表单中的所有按钮或验证所有文本框的数据.有任何想法吗?提前致谢!

c# forms controls containers

5
推荐指数
2
解决办法
2万
查看次数

如何更改Control的不透明度?

我想根据窗体上的鼠标位置更改控件的不透明度,这可能吗?

c# winforms

5
推荐指数
1
解决办法
1万
查看次数

部署.NET应用程序时出现InvalidDeploymentException错误

我有两个项目:Inventario,Produccion Dampers和我说Inventario作为一个参考Produccion Dampers.当我发布时,Produccion Dampers我没有收到错误,但是当我尝试安装时,我收到此错误:

Following errors were detected during this operation.
    * [2/11/2010 3:33:34 PM] System.Deployment.Application.InvalidDeploymentException (RefDefValidation)
        - Reference in the manifest does not match the identity of the downloaded assembly Inventario.exe.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.DownloadManager.ProcessDownloadedFile(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.FileDownloader.DownloadModifiedEventHandler.Invoke(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
            at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
            at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
            at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification …
Run Code Online (Sandbox Code Playgroud)

.net c# deployment publishing winforms

5
推荐指数
1
解决办法
3658
查看次数

如何向表单动态添加(未知类型)控件?

您好我想用一般方法添加控件到我的表单,如下所示:

void addcontrol(Type quien)
{
    this.Controls.Add(new quien);            
}

private void btnNewControl_Click(object sender, EventArgs e)
{
    addcontrol(typeof(Button));
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

c# controls winforms

4
推荐指数
1
解决办法
3442
查看次数

部署使用LINQ to Entities的应用程序

我想使用L2E,因为它对我公司的应用非常方便,我创建了一个演示项目,演示确实在每台机器上运行但是当我说,按下一个按钮,其中包含一些使用该实体的代码我得到了这个错误:

specified store provider cannot be found in the configuration, or is not valid.
Run Code Online (Sandbox Code Playgroud)

请注意,我只在没有安装VS2008的机器上得到此错误,在这些机器上(VS2008的机器),该演示效果很好.任何建议表示赞赏.

我正在使用MySql服务器与Mysql Conector 6.3,并使用ADO.Net权利模型创建模型.

编辑

这是完整的错误跟踪:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
   at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   --- …
Run Code Online (Sandbox Code Playgroud)

c# mysql linq-to-entities entity-framework winforms

4
推荐指数
1
解决办法
2万
查看次数

通用的InBetween函数

我厌倦了写作,x > min && x < max所以我想写一个简单的函数,但我不确定我是否做得对...实际上我不是因为我得到一个错误:

    bool inBetween<T>(T x, T min, T max) where T:IComparable
    {
        return (x > min && x < max);
    }
Run Code Online (Sandbox Code Playgroud)

错误:

Operator '>' cannot be applied to operands of type 'T' and 'T'
Operator '<' cannot be applied to operands of type 'T' and 'T'  
Run Code Online (Sandbox Code Playgroud)

我可能where对函数声明中的部分有一个不好的理解

注意:对于那些打算告诉我我将编写比以前更多的代码的人...想想可读性=)任何帮助将不胜感激

编辑

删除因为它被解决了=)

另一个编辑

所以在经过一番头痛之后,我在@Jay极端可读性的想法之后出现了这个(嗯)的事情:

public static class test
{
    public static comparision Between<T>(this T a,T b) where T : IComparable
    {
        var ttt …
Run Code Online (Sandbox Code Playgroud)

c# generics

4
推荐指数
1
解决办法
217
查看次数