Visual studio 2010 中的自动格式化 lambda 函数
如何设置 Visual Studio 2010,以便多行 lambda 函数不会因为左侧的所有空白区域而显得难看?
dataView.CellFormatting += (s, e) =>
{
if ((e.ColumnIndex == 1)&&((dataView.SelectedCells.Count == 1)))
{
var scope = Scope.Instance;
var row = dataView.Rows[e.RowIndex];
var variable = row.DataBoundItem as Variable;
if (scope.Variables.Contains(variable))
{
dataView[e.ColumnIndex, e.RowIndex].Style.BackColor =
scope.GetGraph(variable).Color;
}
else
{
dataView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White;
}
}
};
How to set up Visual studio 2010 so that multi-line lambda-functions will not look ugly, with all that empty space in the left?
dataView.CellFormatting += (s, e) =>
{
if ((e.ColumnIndex == 1)&&((dataView.SelectedCells.Count == 1)))
{
var scope = Scope.Instance;
var row = dataView.Rows[e.RowIndex];
var variable = row.DataBoundItem as Variable;
if (scope.Variables.Contains(variable))
{
dataView[e.ColumnIndex, e.RowIndex].Style.BackColor =
scope.GetGraph(variable).Color;
}
else
{
dataView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White;
}
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于你认为丑陋的空白有多少,但你可以做的一件事是尽量减少它,那就是在等号后面按回车键。然后你就会得到这样的结果。 `
我通常在进行这样的更改后立即点击 CTRl-E CTRL-D 以使文档自动格式化(编辑->高级->格式文档)
(刚刚看到你修改后的帖子 - 当我将其放入 VS 时并在 += 后按回车键
It depends on how much white space you consider ugly but one thing you can do to minimize it is hit a carriage return right after the equal. Then you end up with something like this. `
I usually hit CTRl-E CTRL-D right after making a change like this to get the document to auto-format (Edit->Advanced->Format Document)
(Just saw your amended post - when I put that in VS and hit return after the +=
这很奇怪——缩进不应该那么远。
尝试将其剪切并粘贴到位,Visual Studio 应该会在粘贴时为您修复它。这就是我得到的:
Now that's odd — the indentation shouldn't go that far.
Try cutting and pasting it in place and Visual Studio should fix it for you on pasting. This is what I get: