From a364562fd3fff8212a2b003047ea9a8b06034167 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Mon, 5 Oct 2020 14:22:47 +0200 Subject: [PATCH] Update ButtonForm.cs - Modifying FilterDuplicate to allow full row filter or not This will keep only the matches, or the full row where it matches. --- TelegramBotBase/Form/ButtonForm.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TelegramBotBase/Form/ButtonForm.cs b/TelegramBotBase/Form/ButtonForm.cs index 47d023b..0bf7da2 100644 --- a/TelegramBotBase/Form/ButtonForm.cs +++ b/TelegramBotBase/Form/ButtonForm.cs @@ -210,7 +210,7 @@ namespace TelegramBotBase.Form /// Creates a copy of this form and filters by the parameter. /// /// - public ButtonForm FilterDuplicate(String filter) + public ButtonForm FilterDuplicate(String filter, bool ByRow = false) { var bf = new ButtonForm() { @@ -226,7 +226,16 @@ namespace TelegramBotBase.Form if (b2.Text.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) == -1) continue; - lst.Add(b2); + //Copy full row, when at least one match has found. + if (ByRow) + { + lst.AddRange(b); + break; + } + else + { + lst.Add(b2); + } } if (lst.Count > 0)