如何设置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;
}
}
};
答案 0 :(得分:2)
这取决于你认为丑陋的白色空间有多少,但是你可以做的最小化它的一件事是在等于之后立即返回回车。然后你最终得到这样的东西。 `
{
var raw_custs =
(from customer in GetActive()
where customer.Name.Contains(name)
select customer).Take(numberToGet).ToList();
我经常在进行此类更改后立即点击CTRL-E CTRL-D以使文档自动格式化(编辑 - >高级 - >格式文档)
(刚看到你修改过的帖子 - 当我把它放在VS中并在+ =
之后点击返回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;
}
}
答案 1 :(得分:1)
现在这很奇怪 - 缩进不应该那么远。
尝试将其剪切并粘贴到位,Visual Studio应该在粘贴时为您修复它。这就是我得到的:
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;
}
}
};