小编Mas*_*son的帖子

如何在拖放过程中自动滚动 DataGridView

我的 C# .NET 应用程序中的一种表单有多个 DataGridViews,它们实现拖放以移动行。拖放大部分工作正常,但我一直很难让 DataGridViews 到 AutoScroll - 当一行被拖动到框的顶部或底部附近时,向那个方向滚动它。

到目前为止,我已经尝试实现解决方案的一个版本。我有一个继承自 DataGridView 的 ScrollingGridView 类,它实现了所描述的计时器,并且根据调试器,计时器正在正确触发,但计时器代码:

const int WM_VSCROLL = 277;
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);

private void ScrollingGridViewTimerTick(object sender, EventArgs e)
{
    SendMessage(Handle, WM_VSCROLL, (IntPtr)scrollDirectionInt, IntPtr.Zero);
}
Run Code Online (Sandbox Code Playgroud)

据我所知,没有做任何事情,可能是因为我在表单中有多个 DataGridView。我也尝试修改 AutoScrollOffset 属性,但这也没有做任何事情。对 DataGridView 和 ScrollBar 类的调查似乎没有建议任何其他命令或函数实际上会使 DataGridView 滚动。任何人都可以帮助我使用实际滚动 DataGridView 的功能,或其他解决问题的方法吗?

c# scroll datagridview

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

为什么ActiveRecord为大多数操作生成参数化查询,而不是为find_by生成参数化查询?

我正在研究一个基本的Rails 4.0应用程序,以了解它是如何工作的,而且我遇到了一些我似乎无法弄清楚的东西.我一直在通过ActiveRecord对默认的Sqlite DB进行查询,对于大多数查询,根据调试输出,它似乎生成参数化查询,如下所示:

2.0.0-p247 :070 > file.save
   (0.2ms)  begin transaction
   SQL (0.6ms)  UPDATE "rep_files" SET "report_id" = ?, "file_name" = ?, "updated_at" = ?
   WHERE "rep_files"."id" = 275  [["report_id", 3], ["file_name", "hello.jpg"],
   ["updated_at", Mon, 09 Sep 2013 04:30:19 UTC +00:00]]
   (28.8ms)  commit transaction
Run Code Online (Sandbox Code Playgroud)

但是,每当我使用find_by进行查询时,似乎只是将提供的参数粘贴到生成的SQL中:

2.0.0-p247 :063 > file = RepFile.find_by(report_id: "29", file_name: "1.png")
  RepFile Load (6.2ms)  SELECT "rep_files".* FROM "rep_files" WHERE
  "rep_files"."report_id" = 29 AND "rep_files"."file_name" = '1.png' LIMIT 1
Run Code Online (Sandbox Code Playgroud)

它确实似乎正在逃避参数以防止SQL注入:

2.0.0-p247 :066 > file = RepFile.find_by(report_id: "29", file_name: "';") …
Run Code Online (Sandbox Code Playgroud)

sql sqlite activerecord ruby-on-rails ruby-on-rails-4

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