如何设置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;
}
}
};
这取决于你认为有多少空白是丑陋的,但是你可以做的一件事就是在等号后面打一个回车。最后就会得到这样的东西。'
{
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;
}
}
这就奇怪了——缩进不应该那么大
尝试剪切并粘贴到适当的位置,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;
}
}
};