小编Dan*_*npe的帖子

"类型'System.Windows.Forms.TreeNodeCollection'没有定义构造函数"

我有这个代码:

    private TreeNodeCollection treeCollection;

    public Client(TcpClient c)
    {
        this.tcpClient = c;
        this.tree = null;
        this.treeCollection = new TreeNodeCollection();
        this.treeCollection.Clear();
    }

    public void AddNode(string node)
    {
        this.treeCollection.Add(node);
    }
Run Code Online (Sandbox Code Playgroud)

this.treeCollection = new TreeNodeCollection();回报

The type 'System.Windows.Forms.TreeNodeCollection' has no constructors defined
Run Code Online (Sandbox Code Playgroud)

如果我删除这一行,我得到的treeCollection从未被分配,并且将始终为null ...

Field 'Client.treeCollection' is never assigned to, and will always have its default value null
Run Code Online (Sandbox Code Playgroud)

如何将treeCollection指定为新的TreeNodeCollection,以便我可以使用AddNode方法向其添加节点?

.net c# collections treeview treenode

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

使用NSFetchedResultsController在空表上自定义单元格

当我的UITableView为空时,我正在尝试放置一个自定义的空单元格.

我使用以下代码:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    int count = [self.fetchedResultsController fetchedObjects].count;
    if (count == 0) {
        return 1;
    }
    return count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = nil;
    int count = [self.fetchedResultsController fetchedObjects].count;
    if (count == 0) {
        // return empty cell
        cell = [self getEmptyCellOfTableView:tableView cellForRowAtIndexPath:indexPath];
    } else {
        cell = [self getMyQuestionCellOfTableView:tableView cellForRowAtIndexPath:indexPath];
    }
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

FRC didChangeObject实现:

- (void)controller:(NSFetchedResultsController *)controller
   didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{       
    if …
Run Code Online (Sandbox Code Playgroud)

core-data objective-c uitableview ios

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

System.NullReferenceException检查是否!= null

我正在使用ASHX处理程序,我希望处理程序检查Session!= null.

if (context.Session["Username"] != null)
Run Code Online (Sandbox Code Playgroud)

我得到这个错误指向这一行:

System.NullReferenceException:未将对象引用设置为对象的实例.

有什么问题?

c# null ashx handler argumentnullexception

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

更改容量时StringBuilder异常!

这是我的代码行:

StringBuilder myCompleteMessage = new StringBuilder();
myCompleteMessage.Capacity = Int32.MaxValue-1;
Run Code Online (Sandbox Code Playgroud)

尝试过:

myCompleteMessage.Capacity = myCompleteMessage.MaxCapacity-1;
Run Code Online (Sandbox Code Playgroud)

我在第2行得到例外.

Exception of type 'System.OutOfMemoryException' was thrown.
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.set_Capacity(Int32 value)
at Orca.Server.HandleClientComm(Object newClient) in C:\Users\Dan\Documents\Visual Studio 2010\Projects\msig\Orca\Server.cs:line 100
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart(Object obj)
Run Code Online (Sandbox Code Playgroud)

.net c# memory stringbuilder exception

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

Concat每4个字符串列表?

我有这个清单:

['192', '168', '0', '1', '80', '192', '168', '0', '2', '8080']...
Run Code Online (Sandbox Code Playgroud)

我想得到这个清单:

['192.168.0.1:80', '192.168.0.2:8080']...
Run Code Online (Sandbox Code Playgroud)

这样做的最佳方式是什么?

使用rangelist流行?

list切片?

python string ip list

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

使用Passport.SocketIO cookie解析器错误

我使用以下内容:

"dependencies": {
    "express": "^4.0.0",
    "socket.io": "0.9.16",
    "mongoose": "^3.8.8",
    "passport": "^0.2.0",
    "passport-local": "^1.0.0",
    "express-session": "^1.0.3",
    "cookie-parser": "^1.0.1",
    "body-parser": "^1.0.2",
    "session-mongoose": "git://github.com/danpe/session-mongoose.git#master",
    "passport.socketio": "^3.0.1"
  }
Run Code Online (Sandbox Code Playgroud)

设置我的socket.io授权:

io.set("authorization", passportSocketIo.authorize({
    passport : passport,
    cookieParser: cookieParser(),
    key:    settings.sessionKey,  //the cookie where express (or connect) stores its session id.
    secret: settings.sessionSecret,       //the session secret to parse the cookie
    store:  sessionStore,  //the session store that express uses
    fail: function(data, accept) {
        console.log("failed");
        // console.log(data);// *optional* callbacks on success or fail
        accept(null, false);             // second param takes …
Run Code Online (Sandbox Code Playgroud)

authentication node.js express socket.io passport.js

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

删除所有无法找到JOIN的行?

我有这个问题:

SELECT Auctions.ID 
FROM Auctions
INNER JOIN Products ON Auctions.ProductID = Products.ID
Run Code Online (Sandbox Code Playgroud)

据我所知,如果我有拍卖:

ID | ProductID
1  |   12
Run Code Online (Sandbox Code Playgroud)

并且ProductID 12不在Products表中,因此不会选择该行.

如果我是对的,我想删除Products表上没有找到产品ID的所有行.(无法找到JOIN的产品)

我怎样才能做到这一点?

sql sql-server select inner-join

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

.NET线程返回值?

可能重复:
从线程返回值?

我有这个代码:

//Asynchronously start the Thread to process the Execute command request.
Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
//Make the thread as background thread.
objThread.IsBackground = true;
//Set the Priority of the thread.
objThread.Priority = ThreadPriority.AboveNormal;
//Start the thread.
objThread.Start(command);
Run Code Online (Sandbox Code Playgroud)

问题是ExecuteCommandSync返回一个字符串.

如何捕获返回的字符串并将其返回?

.net c# multithreading return-value

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

PostMessage WM_KEYDOWN发送乘法键?

我有以下代码:

    public static void Next()
    {
        Process[] processes = Process.GetProcessesByName("test");

        foreach (Process proc in processes)
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
    }
Run Code Online (Sandbox Code Playgroud)

此代码发送了向右箭头键,我想发送ALT + CTRL + RIGHT,我尝试了以下操作:

    public static void Forward()
    {
        Process[] processes = Process.GetProcessesByName("test");

        foreach (Process proc in processes)
        {
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_CONTROL, 0);
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_ALT, 0);
            PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
        }
    }
Run Code Online (Sandbox Code Playgroud)

但这行不通...

有任何想法吗?

.net c# winapi postmessage process

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

`gem_original_require':没有要加载的文件 - rvm/capistrano(LoadError)

我在使用RVM的Ubuntu 12.04,Ruby 1.9.3,Rails 3.2.8.

昨天我用Capistrano就好了,我重新启动了我的ubuntu,现在我正在尝试使用capistrano部署我得到这个:

$ cap deploy
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- rvm/capistrano (LoadError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:152:in `require'
    from ./config/deploy.rb:4:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:89:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `each'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `load'
    from Capfile:5:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:89:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `each'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/configuration/loading.rb:86:in `load'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/cli/execute.rb:65:in `load_recipes'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/cli/execute.rb:65:in `each'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/cli/execute.rb:65:in `load_recipes'
    from /var/lib/gems/1.8/gems/capistrano-2.13.4/lib/capistrano/cli/execute.rb:31:in `execute!'
    from …
Run Code Online (Sandbox Code Playgroud)

ruby gem capistrano ruby-on-rails rvm

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