Mám grid, že se snažím chcete-li odstranit položku v konkrétní řádek. Je to ve smyčce, pak když přejde na druhý řádek, odstraňuje položky v druhé linii a TAKÉ v prvním řádku. Jak mohu nastavit, aby odstranit pouze řádek, který chci?
Všimněte si, že to, co se snažím udělat, je zkopírovat první řádek na druhé jen řešení pow (b2), a v třetím řádku jsem se zkopírovat druhý řádek, ale řešit -4 * 5 (-4 *).
Toto je náhled toho, co se děje.
Toto je můj kód k nafouknutí tyto řádky, aby pochopili:
Vstoupí první v if(fields == null)
protože je pow, po které chodí do else
:
for (int i = 0; i < qntLines; i++)
{
string field = lines[i].Substring(0, lines[i].IndexOf('#'));
string operation = lines[i].Substring(lines[i].IndexOf('#') + "#".Length);
CreateResultLine(field, operation, i, listTexts);
}
private void CreateResultLine(string field, string operation, int i, List<string> listTexts)
{
string[] fields = null;
List<string> texts = new List<string>();
string text = string.Empty;
dynamic textResult;
int count = new int();
if (field.Contains(','))
fields = field.Split(',', (char)StringSplitOptions.RemoveEmptyEntries);
if (fields == null)
{
text = listTexts[int.Parse(field)];
text = RemovePow(text);
texts.Add(text);
textResult = ExecuteOperation(texts, operation);
gridFrame.Children.RemoveAt(int.Parse(field) + 1);
gridFrame.Children.Add(new Label() { Text = textResult.ToString(), HorizontalTextAlignment = TextAlignment.Center,
TextColor = Color.Blue, HorizontalOptions = LayoutOptions.Center }, int.Parse(field) + 1, i);
}
else
{
foreach (var item in fields)
{
string noPow = string.Empty;
noPow = RemovePow(listTexts[int.Parse(item)]);
texts.Add(noPow);
++count;
}
textResult = ExecuteOperation(texts, operation);
for (int i2 = int.Parse(fields[0]); i2 <= int.Parse(fields[1]);)
{
gridFrame.Children.RemoveAt(int.Parse(fields[0]));
++i2;
}
gridFrame.Children.Add(new Label() { Text = textResult.ToString(), HorizontalTextAlignment = TextAlignment.Center,
TextColor = Color.Blue, HorizontalOptions = LayoutOptions.Center }, int.Parse(fields[0]) + 1, i);
}
}