小编unb*_*ced的帖子

是否可以在没有SQL Server的情况下访问.mdf数据库?

.mdf通过SQL Server 创建了一个文件并将其放到本地文件中.我在没有安装SQL Server的计算机上运行我的程序.我还使用了System.Data.SqlClient命名空间中的类(即SqlConnection..)

我想与.mdfSQL Server创建的文件进行某种访问连接?可能吗 ?

c# sql-server mdf

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

在JQuery中读取隐藏列的值

我需要在表上隐藏一列,但之后我无法读取所选行的隐藏列值.

 dtTable = $('#lookupTable').DataTable({
       "columnDefs": [
           {
               "targets": [ 0 ],
               "visible": false,
               "searchable": false               
           }
        ],  

        aaData: data,
        aoColumns: cols,
        paging: false,
        scrollCollapse: true,
        destroy: true

    });
Run Code Online (Sandbox Code Playgroud)

如你所见,现在隐藏了第一列.我试图用该代码读取列值

    selectedIndex = $(this).find('td:eq(0)').text(); 
Run Code Online (Sandbox Code Playgroud)

如果我从代码中删除<"visible":false>,我可以读取第一列的值,但如果它被隐藏,它会给我第二列值.

我厌倦了改变"witdh"的财产,但它没有工作..

jquery datatables

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

如何在android上获得按钮的背景颜色?

我想获得按钮的颜色..我无法从返回drawable的getbackground函数获得颜色.我使用了getsolidcolor,它返回整数值,但它一直是0(零)..我不明白问题出在哪里.也许它不是真正的功能..

这是我的android代码

            int renk = btn1.getSolidColor();

        if(renk== Color.GREEN)
            Toast.makeText(getApplicationContext(), "green" , 1000).show();
        else if(renk== Color.RED)
            Toast.makeText(getApplicationContext(), "red" , 1000).show();
        else if(renk== Color.YELLOW)
            Toast.makeText(getApplicationContext(), "yellow" , 1000).show();
        else
            Toast.makeText(getApplicationContext(), "unknown", 1000).show();

        btn1.setBackgroundColor(Color.YELLOW);
     renk = btn1.getSolidColor();


        if(renk== Color.GREEN)
            Toast.makeText(getApplicationContext(), "green" , 1000).show();
        else if(renk== Color.RED)
            Toast.makeText(getApplicationContext(), "red" , 1000).show();
        else if(renk== Color.YELLOW)
            Toast.makeText(getApplicationContext(), "yellow" , 1000).show();
        else
            Toast.makeText(getApplicationContext(), "unknown", 1000).show();
Run Code Online (Sandbox Code Playgroud)

即使我将背景设置为黄色,我也会得到未知的吐司消息.

android background-color

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

如何使用Parallel.For?

我想在我的项目(WPF)中使用并行编程.这是我的for循环代码.

for (int i = 0; i < results.Count; i++)
{
    product p = new product();

    Common.SelectedOldColor = p.Background;
    p.VideoInfo = results[i];
    Common.Products.Add(p, false);
    p.Visibility = System.Windows.Visibility.Hidden;
    p.Drop_Event += new product.DragDropEvent(p_Drop_Event);
    main.Children.Add(p);
}
Run Code Online (Sandbox Code Playgroud)

它没有任何问题.我想用Parallel.For写它,我写了这个

Parallel.For(0, results.Count, i =>
{
    product p = new product();
    Common.SelectedOldColor = p.Background;
    p.VideoInfo = results[i];
    Common.Products.Add(p, false);
    p.Visibility = System.Windows.Visibility.Hidden;
    p.Drop_Event += new product.DragDropEvent(p_Drop_Event);
    main.Children.Add(p);
});
Run Code Online (Sandbox Code Playgroud)

但是在producd类的构造函数中出现错误

调用线程必须是STA,因为许多UI组件都需要这个.

那么我使用了Dispatcher.这是代码

Parallel.For(0, results.Count, i =>
{
    this.Dispatcher.BeginInvoke(new Action(() =>
        product p = new product();
        Common.SelectedOldColor = p.Background; …
Run Code Online (Sandbox Code Playgroud)

c# parallel-for

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

如何在.net上为WebClient设置TimeOut?

我下载了一些文件,但我也想为webclient设置超时.我看到没有变化只是我们可以使用重写WebRequest.我已经做了但它不起作用.我的意思是重写GetWebRequest方法不起作用..这是我的代码

  public class VideoDownloader : Downloader
{
    /// <summary>
    /// Initializes a new instance of the <see cref="VideoDownloader"/> class.
    /// </summary>
    /// <param name="video">The video to download.</param>
    /// <param name="savePath">The path to save the video.</param>
    public VideoDownloader(VideoInfo video, string savePath)
        : base(video, savePath)
    { }


    /// <summary>
    /// Starts the video download.
    /// </summary>
    public override void Execute()
    {
        // We need a handle to keep the method synchronously
        var handle = new ManualResetEvent(false);

        var client = new WebClient();


        client.DownloadFileCompleted …
Run Code Online (Sandbox Code Playgroud)

c# timeout webclient webrequest downloadfileasync

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

Visual Studio Intellisense列表为空

当我在某个项目中编写代码时,会弹出Intellisense窗口,但列表为空(就像项目不可见),当我尝试单击时,没有任何反应.

空智能感知列表

没有建议清单

在我看到Intellisense窗口没有弹出但我有不同的问题之前.

所以我要解决的问题是:

  1. 选项窗口中的已检查项目
  2. 删除了suo文件,
  3. 重置用户设置
  4. 重启VS和机器

我打开另一个项目,它的工作原理.但对于某个项目,它没有.我用谷歌搜索但没有发现任何类似的问题.

问题刚刚发生.

我正在使用VS 2015,版本14 Update 2

c# intellisense visual-studio-2015

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

从互联网获取图像时有趣的例外

我正在开发一个WPF程序,从网上获取图片并使用图像控件.我的图片列表有50张图片(来自vimeo的缩略图).一切看起来很好但是数字45.图片有一些问题,当我到达第45张图片时,我得到了这个例外:

价值不在预期范围内.

例外http://img232.imageshack.us/img232/2748/5688301315b2497090468bc.png

我用try-catch但是我抓不住它.因为它出现在Bitmap类中.以下是详细信息:

   at System.Windows.Media.ColorContext.GetColorContextsHelper(GetColorContextsDelegate getColorContexts)
   at System.Windows.Media.Imaging.BitmapFrameDecode.get_ColorContexts()
   at System.Windows.Media.Imaging.BitmapImage.FinalizeCreation()
   at System.Windows.Media.Imaging.BitmapImage.OnDownloadCompleted(Object sender, EventArgs e)
   at System.Windows.Media.UniqueEventHelper.InvokeEvents(Object sender, EventArgs args)
   at System.Windows.Media.Imaging.LateBoundBitmapDecoder.DownloadCallback(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 …

c# wpf image argumentexception

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

Visual Studio Ultimate 2012 RC是否支持MySQL实体?

为.Net v6.5安装了 MySQL连接器,它得到了Entity Framework的支持.当我使用Visual Studio 2012并尝试添加ADO.NET实体数据模型时,我看不到MySQL.只有Microsoft SQL Server.它在VS 2010中有效.

这个问题说他们正在研究它 - 有结论吗?

mysql entity-framework visual-studio-2012

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

Linq不同类型的Condtion

我有一个从ProfileBase派生的列表.此列表可以包含Profile,DynamicViewProfile的实例,因为它们都是从ProfileBase派生的

但是如果项目类型是DynamicViewProfile,我必须使用NodeName,如果是Profile,那么我应该使用DocName

profileListsForSearch = profileLists.Where(stringToCheck =>
((Profile)stringToCheck).DocName.Contains(searchBar.Text)).ToList();
Run Code Online (Sandbox Code Playgroud)

所以这是用于配置文件,它没关系,但如果列表包含DynamicViewProfile对象,那么我有一个例外,因为docname为null我需要获取NodeName

我希望我的问题很清楚

c# linq

0
推荐指数
1
解决办法
72
查看次数