Is it possible to pass or replace part of control name? - c#

first of all I would like you to brace yourselves.
I have started programming only around 6 weeks ago. I do apologize if anything facepalm worthy follows.
I was wondering if it is possible to pass only part of a control name?
This is the idea:
I have two teams, Class is set up like this:
public class Team
{
int _established; //could be string
string _name;
double _best
}
//Snip
I have 2 sets of forms, both identical for input, but the only difference are the names:
//Team 1
team1Year.Text = "";
team1Name.Text = "";
team1Numericupdown.Value = 0;
//Team 2
team2Year.Text = "";
team2Name.Text = "";
team2Numericupdown.Value = 0;
So, it is essentially the same. I was wondering if it is possible to create a method that would do the following:
//Snip
Team team1 = new Team()
Team team2 = new Team()
//Not specific to problem, values can be anything
team1.estYear = 2008;
team1.Name = "Teamname1";
team1.Best = 137.8;
team2.estYear = 2009;
team2.Name = "GenericName";
team2.Best = 134.3;
private void HowToMethod(string tm, Team values)
{
//so it would become like this - replace team1 and team2 with an argument
tmYear.Text = values;
tmName.Text = values;
tmNumericupdown.Value = values;
}
And in practice:
HowToMethod(team1, team1.estYear)
//Output: team1Year.Text = 2008;
HowToMethod(team1, team1.Name)
//Output: team1Name.Text = Teamname1;
HowToMethod(team2, team2.Best)
//Output: team2Numericupdown.Value = 134.3;
This is not mandatory, I was just wondering if such thing is possible. I am fine with not having solution to this. There are different control/forms present, not all are the same, but they belong to the same "group" by name.
I hope it was not too confusing.
EDIT1:
So i have tried to be less confusing. Again, I do apologize for the facepalm. English is also not my first language, which also doesn't help. Anyways, here it goes:
This works, but to me it looks like repetitive code.
I was wondering if there is a simpler solution
...that is not an advanced topic
private void button1_Click(object sender, EventArgs e)
{
//Just one example. It's about manipulating Forms/Controls via code
//Lock Team1's controls
team1Year.Enabled = false;
team1Name.Enabled = false;
team1NumericUpDown.Enabled = false;
//Lock Team 2's Controls
team2Year.Enabled = false;
team2Name.Enabled = false;
team2NumericUpDown.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
//Another button unlocks
//Unlock Team1's controls
team1Year.Enabled = true;
team1Name.Enabled = true;
team1NumericUpDown.Enabled = true;
//Unlock Team 2's Controls
team2Year.Enabled = true;
team2Name.Enabled = true;
team2NumericUpDown.Enabled = true;
}
Ok, so the above works - manually pick the controls we want to disable
Can it be something like this:
Apologies if not using proper object types
private void MyMethod(int X, bool isItEnabled)
{
//This feels so, so wrong
Control ctrl = sender as Control;
team{X}Year.Enabled ;
team{X}Name.Enabled = {isItEnabled};
team{X}NumericUpDown.Enabled = {isItEnabled};
}
//In action:
private void button1_Click(object sender, EventArgs e)
{
MyMethod(1, false)
//Would mean/become:
team{1}Year.Enabled = {false};
team{1}Name.Enabled = {false};
team{1}NumericUpDown.Enabled = {false};
//Or if the method was implemented differently:
private void MyMethod(string prefix, bool isItEnabled)
{
{prefix}Year.Enabled ;
{prefix}Name.Enabled = {isItEnabled};
{prefix}NumericUpDown.Enabled = {isItEnabled};
}
//In action:
MyMethod(team2, true)
//Would mean:
{team2}Year.Enabled = {true};
{team2}Name.Enabled = {true};
{team2}NumericUpDown.Enabled = {true};
So the arguments passed could replace only part of the control name
if they have a shared sequential name
In conclusion:
** Is it possible to introduce a variable to replace part of code for modularity**:
//Making the idea into a method would be secondary
could become:
X = "team1";
Properties.Settings.Default.{X}Totals;
{X}Year.Text = "";
{X}Name.Text = "";
{X}Whatever.Text = "";
{X}NumericUpDown.Value = 135;
I know it works with Classes:
private void TeamStuff(Team teamID, string value1, string value2)
{
teamID.Year = value;
teamID.Name = value;
//...etc
}
//then
TeamStuff (team1, "sample", "GenericName");
//becomes
team1.Year = "sample";
team1.Name = "GenericName";

I really dont know what you are trying to do, and i guess that there may be better ways to do it,but to answer your specific question, here is the implementation of HowToMethod
private void HowToMethod(string tm, Team values)
{
var yearControlName = tm + "Year";
foreach(var ctrl in Controls)
{
if (ctrl is TextBox)
{
var tb = (ctrl as TextBox);
if (tb.Name == yearControlName)
tb.Text = values.EstYear.ToString();
}
}
}
Its only for showing the EstYear but is enough for you to try yourself and implement the rest,
P.S. Surely this code can be shorter with Linq but for sake of simplicity as the OP is new programmer lets keep it this way.
Edit
Now things are more clarified, the answer is no, u cant do that the way you did it, if you want to select a control based on a variable value (Which is fine in certain circumstances) , thats fine, but you have to do somthing like I showed in above code, i.e. iterate through all controls and check if the name is equal to your desire.
The fact is your code goes through a compile progress and for compiler the acceptable name of a control for example, is the actuall text you written there, not a combination of variables that may produce the same name, why? Because variables dont get their value until you run your code and that is after you compiled your code and without correct name compiler fails.

Related

Access data in datagridview from a class

I've read a lot of topics on this issue but I'm not finding an answer. I'm fairly new to this so please bear with me.
I'm trying to pass values from datagridview to a list. And then in a new class I want to make som methods accessing that list. Trouble is that when I pass the datagridview it returns it without content and values which means I can't do anything with it.
The code under ////TESTING//// works like I want. I create an instance of the specified list and it's counting the amount of rows properly, see screenshot.
public List<vertEl> getVertList = new List<vertEl>();
//Opens the file dialog and assigns file path to Textbox
OpenFileDialog browseButton = new OpenFileDialog();
private void browse_Click(object sender, EventArgs e)
{
browseButton.Filter = "Excel Files |*.xlsx;*.xls;*.xlsm;*.csv";
if (browseButton.ShowDialog() == DialogResult.OK)
{
//SOME CODE TO GET DATA FROM EXCEL AND SOME METHODS TO CALCULATE
//VALUES TO PASS TO THE TAB VERTIKALELEMENTER TAB IN MY DATAGRIDVIEW
//VERTIKALELEMENTER IS vertElementerDgv IN MY CODE
////TESTING////
GetVertElementasList TEST = new GetVertElementasList();
getVertList = TEST.vertList(vertElementerDgv);
MessageBox.Show(getVertList.Count.ToString());
}
else return;
}
I now want to do this in a seperate class and call a method from that class to do the same but when I try that with code underneath I do not get the same count as when I have the code in form1 (public partial class BridgeGeometry). It return count of 0. The method foo() is assigned to the button 1 in the form.
class GetKoord
{
public GetVertElementasList getList = new GetVertElementasList();
BridgGeometry obj = new BridgGeometry();
public void foo()
{
var TEST = getList.vertList(obj.vertElementerDgv);
//var TEST = obj.getVertList;
MessageBox.Show(TEST.Count.ToString());
}
}
I also tried to get the values directly from the datagridview but there's nothing in it when I access it from a class which is not the form1/BridgeGeometry class.
Form - screenshot
You could run a loop and store the information with selected rows into a public var with something like this:
string itemOne = dataGridView1.SelectedRows[0].Cells[1].Value + string.Empty;
string itemTwo= dataGridView1.SelectedRows[0].Cells[2].Value + string.Empty;
string itemThree = dgMasterGridBun.SelectedRows[0].Cells[3].Value + string.Empty;
Variables
public var varItemOne = itemOne;
public var varItemTwo = itemTwo;
public var varItemThree = itemThree;
Based on the link I managed to get this working. Probably not the best solution, but a working one. I tried to wrap my head around databinding, listbinding etc. but since the class with the input values are a messy one I gave that up for now. The datagriview input values are a little from lists and some from other datagridview.
MSDN-forum: Accessing Form1 controls from a different class
Explanations are given in the link so I'll just provide how I did it in my program.
If my GetKoord class are like this:
public class GetKoord
{
private BridgGeometry bridgeGeometry;
public GetKoord(BridgGeometry form1)
{
bridgeGeometry = form1;
}
public List<vertElementerParam> getListvertElementer(List<vertElementerParam> theList)
{
//var vertElementerDgv = bridgeGeometry.vertElementerDgv;
GetVertElementasList getVertElementasList = new GetVertElementasList();
List<vertElementerParam> MyDgvListList = new List<vertElementerParam>();
MyDgvListList = getVertElementasList.vertList(bridgeGeometry.vertElementerDgv);
//MessageBox.Show(MyDgvListList.Count.ToString());
theList = MyDgvListList;
return theList;
}
}
then I can get the list in Button1_Click like this, check the screenshot in the first post:
public List<vertElementerParam> getVertList = new List<vertElementerParam>();
private void button1_Click(object sender, EventArgs e)
{
GetKoord getKoord = new GetKoord(this);
List<vertElementerParam> testList = new List<vertElementerParam>();
testList = getKoord.getListvertElementer(getVertList);
MessageBox.Show(testList.Count.ToString());
}

How to highlight HTML syntax in C# windows form RichTextBox?

I am writing a c# Html editor application, in which you type the code in a RichTextBox control. I want the RichTextBox to behave like notepad++ and other code editors in which the Html syntax gets highlighted in colors, like this for example:
How can I establish this in C# windows form RichTextBox? I have searched almost everywhere and didn't find anything that helped me. This is what I tried so far but I doesn't give the result I want:
private void SyntaxHighlight()
{
string[] tags = { "html","head","body","a","b","img","strong","p","h1","h2","h3","h4","h5","h6","embed","iframe","span","form",
"button","input","textarea","br","div","style","script","table","tr","td","th","i","u","link","meta","title"};
foreach (string s in tags)
{
richTextBox1.Find("<" + s);
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.Find(">");
richTextBox1.SelectionColor = Color.Blue;
}
string[] attributes = { "href","src","height","width","rowspan","colspan","target","style","onclick","id","name","class"};
foreach (string s in attributes)
{
richTextBox1.Find(s + "=");
richTextBox1.SelectionColor = Color.Red;
}
}
Can someone help me? What should I write inside the SyntaxHighlight() method? can someone give me the appropriate code?
Thank you
Within your code you are only finding the 1st occurrence of the HTML tag and highlighting it. But instead, you should loop through the entire rich text content to finding proceeding occurrences of the same text. I just did a quick mock based on your exact code, please check it out.
private void highlightHTMLText()
{
string[] tags = { "html","head","body","a","b","img","strong","p","h1","h2","h3","h4","h5","h6","embed","iframe","span","form",
"button","input","textarea","br","div","style","script","table","tr","td","th","i","u","link","meta","title"};
foreach (string s in tags)
{
findAndHighlight("<" + s, Color.Blue);
findAndHighlight("</" + s, Color.Blue);
findAndHighlight(">", Color.Blue);
}
string[] attributes = { "href", "src", "height", "width", "rowspan", "colspan", "target", "style", "onclick", "id", "name", "class" };
foreach (string s in attributes)
{
findAndHighlight(s + "=", Color.Red);
}
}
private void findAndHighlight(string sSearchStr, Color oColor)
{
int index = richTextBox1.Text.IndexOf(sSearchStr);
while (index != -1)
{
richTextBox1.Select(index, sSearchStr.Length);
richTextBox1.SelectionColor = oColor;
index = richTextBox1.Text.IndexOf(sSearchStr, index + sSearchStr.Length);
}
}
Further as per this answer you should be able to make use of the same utility library Scintilla used by Notepad++ itself. As pointed out you do not need to re-invent the wheel, but as a developer I obviously prefer my own util (it is just me ;) ). Hope this helps.
Find doesn't move a cursor, it returns the location of the first match. Try this instead:
How to select text from the RichTextBox and then color it?
A little late to the party but, after wanting to create my own offline version of CodePen, I implemented my own version of html syntax highlighting following CodePen's theme.
This does syntax highlighting and markup formatting, though the formatting depends on whether or not your html is well-formed.
Just add this as a class for your RichTextBox, instantiate it accordingly and call it within whichever event works for you (I'm using it with the RTB's double_click event but that does eliminate double-click text selection). What I'm planning to do is add a timer, some boolean variables and work this within the key_up and key_down events to set the highlight update to be a bit more automatic and less intrusive on shortcuts. (which is hereby included below the class)
public void HighlightHTM(RichTextBox Htm_Input)
{
Htm_Input.Visible = false;
#region store the original caret position + forecolor
int originalIndex = Htm_Input.SelectionStart;
int originalLength = Htm_Input.SelectionLength;
Color originalColor = Color.FromArgb(200, 200, 200); // Grey
#endregion
#region try to format the markup
try { Htm_Input.Text = XElement.Parse(Htm_Input.Text).ToString(); } catch { }
#endregion
#region match everything but puncutation and equals
Regex e = new Regex(#"(.*?|=)[^\w\s]");
MatchCollection eMatches = e.Matches(Htm_Input.Text);
foreach (Match m in eMatches)
{
Htm_Input.SelectionStart = m.Groups[1].Index;
Htm_Input.SelectionLength = m.Groups[1].Length;
Htm_Input.SelectionColor = Color.FromArgb(221, 202, 126); // Yellow
}
#endregion
#region match tags
Regex t = new Regex(#"(<\w+|</\w+|/>|>)[^=]");
MatchCollection tMatches = t.Matches(Htm_Input.Text, 0);
foreach (Match m in tMatches)
{
Htm_Input.SelectionStart = m.Groups[1].Index;
Htm_Input.SelectionLength = m.Groups[1].Length;
Htm_Input.SelectionColor = Color.FromArgb(167, 146, 90); // Brown
}
#endregion
#region match quotes
Regex q = new Regex("\".*?\"");
MatchCollection qMatches = q.Matches(Htm_Input.Text);
foreach (Match m in qMatches)
{
Htm_Input.SelectionStart = m.Index;
Htm_Input.SelectionLength = m.Length;
Htm_Input.SelectionColor = Color.FromArgb(150, 179, 138); // Green
}
#endregion
#region match inner html
Regex h = new Regex(">(.+?)<");
MatchCollection hMatches = h.Matches(Htm_Input.Text);
foreach (Match m in hMatches)
{
Htm_Input.SelectionStart = m.Groups[1].Index;
Htm_Input.SelectionLength = m.Groups[1].Length;
Htm_Input.SelectionColor = Color.FromArgb(200, 200, 200); // Grey
}
#endregion
#region restoring the original colors, for further writing
Htm_Input.SelectionStart = originalIndex;
Htm_Input.SelectionLength = originalLength;
Htm_Input.SelectionColor = originalColor; // Light Grey
#endregion
Htm_Input.Focus();
Htm_Input.Visible = true;
}
Happy coding!
Edit: I should also mention that !doctype breaks formatting as it's not exactly xml-friendly in the context of "well-formed". For my purposes, all tags including body and relevant closings, css and js links are added programmatically at page save so only markup within the body tags are worked with inside the html RTB. This eliminates that problem.
You'll notice that this relies exclusively on Regex rather than on hard-coded tags and properties. I did this because tags and properties have a tendency to pop on and off the w3 scene quite often. That would force a dev to continually have to go back and edit those strings to remove deprecated tags / properties or to add new. Not optimal.
I also thought it prudent to go ahead and include the instantiation / usage examples to make this a bit more plug&play.
Above public Main(), instantiate like so:
#region Class Instantiation
SyntaxHighlight syntax = new SyntaxHighlight();
#endregion
... and, within your chosen event handler, call it like so:
private void htm_input_DoubleClick(object sender, EventArgs e)
{
syntax.HighlightHTM(Htm_Input);
}
Naturally, adding a SaveFileDialog and an OpenFileDialog pretty much provides this the functionality of your very own, albeit very basic, html editor. Toss in a WebBrowser control and apply the RTB's text as the WebBrowser's source and you've upgraded to live-view.
In the very least, this should serve as a viable reference for syntax highlighting in general. It really just boils down to identifying patterns and manipulating their colors so, for example, this will work effectively with css, javascript and even C# with some light adjusting of the pattern identification parameters.
The following is how I setup the automatic refresh with key_up / key_down and a timer set to 1000 ms:
#region Globals
int r = 0;
bool refresh = false;
#endregion
private void Htm_Input_KeyUp(object sender, KeyEventArgs e)
{
refresh = true; // enter refresh cycle
}
private void Htm_Input_KeyDown(object sender, KeyEventArgs e)
{
refresh = false; // abort refresh cycle
}
private void Timer_Refresh_Tick(object sender, EventArgs e)
{
// check if refresh cycle is entered, refresh at 3 seconds or reset the counter if aborted
if (refresh) { if (r == 3) { syntax.HighlightHTM(Htm_Input); refresh = false; r = 0; } r++; } else { r = 0; }
}

How can I clear textboxes so submit button can be re-used?

I am making a program for school in C#, and its purpose is to allow the user to enter film data, which it then puts into an object for that film. It will also include other functionality such as the user being able to search for a film (it says I have to make 3 film objects and store them in an array all being input by the user).
I have created the first part of the Windows Forms application and it is a screen that gets all the input from the user like the name, director, rating, etc... and there is a submit button which creates the object. Is there a way, without creating a new form, to use the same screen and clear the textboxes so that when the submit button is clicked again it creates a NEW OBJECT like 'film2'?
Here is my code for the submit button:
private void button1_Click(object sender, EventArgs e)
{
int year = Convert.ToInt32(dBox_year.Text);
Film film1 = new Film(tbox_name.Text, tbox_director.Text, tbox_actor1.Text, tbox_actor2.Text, year, tbox_rating.Text);
filmArray[0] = film1;
}
So, you see how I would like to have the textboxes on the main screen clear themselves, and reuse the same screen but only it would be 'Film film2 = ...' etc.
This is not an assesed piece and we haven't covered this in class yet so I have tried.
private void button1_Click(object sender, EventArgs e)
{
int year = Convert.ToInt32(dBox_year.Text);
Film film1 = new Film(tbox_name.Text, tbox_director.Text, tbox_actor1.Text, tbox_actor2.Text, year, tbox_rating.Text);
filmArray[0] = film1;
//clearing after adding to array
//or you can just use .Clear() method
tbox_name.Text = String.Empty;
tbox_director.Text = String.Empty;
tbox_actor1.Text = String.Empty;
tbox_actor2.Text = String.Empty;
tbox_rating.Text = String.Empty;
}
tbox_name.Clear() - Clears all text from the text box control.(Inherited from TextBoxBase.)
You could use a List instead of an Array, declared at form level:
private List<Film> filmList = new List<Film>();
Then your button click even would look like
private void button1_Click(object sender, EventArgs e)
{
int year = Convert.ToInt32(dBox_year.Text);
filmList.Add(new Film(tbox_name.Text, tbox_director.Text, tbox_actor1.Text, tbox_actor2.Text, year, tbox_rating.Text));
tbox_name.Text = string.Empty;
tbox_director.Text = string.Empty;
tbox_actor1.Text = string.Empty;
tbox_actor2.Text = string.Empty;
tbox_rating.Text = string.Empty;
dBox_year.Text = string.Empty;
}
Here you're creating a new Film object and adding it straight away to the list of films, and then clearing the text boxes afterwards.
If there's a specific reason you need an array, then you can always later do
filmList.ToArray()
Hope this helps!
When Submit button is clicked you want to add the object at the end of the array, not put it at the first position.So you will need an extra variable named, let say, filmCount, which you initialize with 0 and increment on each submit.
Film film1 = new Film(tbox_name.Text, tbox_director.Text, tbox_actor1.Text, tbox_actor2.Text, year, tbox_rating.Text);
filmArray[filmCount++] = film1;
then you clear the texboxes
foreach(TextBox TB in this.Controls)
{
TB.Text = "";
}

ProcessBar counter C#

I have a question about the ProcessBar on C#,
How would I add the value of 1 to a label if the method used when passing an item within a list box was successful ?
I have a method like this
private static Form1 f1 = Application.OpenForms["Form1"] as Form1;
public static void GroupList1(processBar bar)
{
f1.listBox1.Items.Add("User1");
bar.Value = 100;
}
public static void GroupList2(processBar bar2)
{
f1.listBox1.Items.Add("User2");
bar.Value = 100;
} // Etc, etc - up to GroupList6
I would also like to have a label that tells me how many user's were successfully added (using the bar), I was thinking of adding a method like this :
if (bar.Value = 100)
{
f1.label1.Text = "" + 1;
}
Inside of my GroupList1/2 method, but the label always appears as the value 1 .
This method within the main form of my code loads a separate label :
for(int i = 0; int i < listBox1.Items.Count; i++)
{
label2.Text = i.ToString();
}
So, I would like label 1 to increase by 1 if the user has been loaded into my list box successfully, how would I do this ?
Obviously this isn't actually the code I'm using within my program, a method is used if the selected index changes (which is why I want to increase by 1, to ensure the user parsed the method successfully), but the question still remains as described, thanks.
I dont quite understand well what are you trying to achieve, but if you only look in increasing the value of such label then you can easily do this by
if (bar.Value = 100)
{
f1.label1.Text = ""+(int.Parse(f1.label1.Text)+1);
}
or even a better way to initialize the string if for some reason the Text of the label is not an integer
if (bar.Value == 100)
{
int value;
if(!int.TryParse(f1.label1.Text,out value))
{
f1.label1.Text = "1";
}
else
{
f1.label1.Text = ""+(value+1);
}
}
but the best way to do this is to keep track of the value in a separate variable and just update the content of the label.
It's a bad idea to store the actual count in the label's Text property, instead, create a variable:
private static int count;
Now, change your code to something like this:
if (bar.Value = 100)
{
// Add 1
count += 1;
// Update the UI
f1.label1.Text = count.ToString();
}

Win 8.1 SearchBox SuggestionsRequested

I got an userControl that contains a searchBox.
This UserControl is inside another one.
I got a strange behavior while i'm searching, because the suggestionCollection works in a strange way.
Example :
in the searchBox i write something all works perfectly, if i choose the item it also works.
But if i try to use backspace (after the choose) i got no suggestion.
I cannot understand why it doesn't work.
That's the code
//var deferral = args.Request.GetDeferral(); //it seems to not influence the behavior
var suggestionCollection = args.Request.SearchSuggestionCollection;
try
{
TransporterExt tr_search = new TransporterExt();
//queryText is a string inserted in the searchBox
if (string.IsNullOrEmpty(queryText)) return;
tr_search.name = queryText;
suggested.Clear(); //that's a collection..
//just a search that return a collection of objects TransporterExt
querySuggestions = await TransporterService.Search_StartsWith(tr_search);
if (querySuggestions.Count > 0)
{
int i = 0;
foreach (TransporterExt tr in querySuggestions)
{
string name = tr.name;
string detail = tr.trId.ToString();
string tag = i.ToString();
string imageAlternate = "imgDesc";
suggestionCollection.AppendResultSuggestion(name, detail, tag, imgRef, imageAlternate);
this.suggested.Add(tr);
i++;
}
}
}
catch (System.ArgumentException exc)
{
//Ignore any exceptions that occur trying to find search suggestions.
Debug.WriteLine(exc.Message);
Debug.WriteLine(exc.StackTrace);
}
//deferralComplete(); //it seems to not influence the behavior
The problem is that: all the variables have the right value, but the suggestion panel appears only if i make a particular search: it appears when i change the first letter of search, or after an wrong seach
What appends when i make a search
What appends if i use the backspace, and i what i want to fix
As i said, all works perfectly, after the "backspace" action the suggestionCollection got the right value...but the panel is missing.
Could someone help me?
You can use SearchBox and SuggestionRequested event to fire the event when type on the SearchBox. I will show an Example
<SearchBox x:Name="SearchBoxSuggestions" SuggestionsRequested="SearchBoxEventsSuggestionsRequested"/>
and write the SearchBoxEventsSuggestionsRequested handler in the code behind
private void SearchBoxEventsSuggestionsRequested(object sender, SearchBoxSuggestionsRequestedEventArgs e)
{
string queryText = e.QueryText;
if (!string.IsNullOrEmpty(queryText))
{
Windows.ApplicationModel.Search.SearchSuggestionCollection suggestionCollection = e.Request.SearchSuggestionCollection;
foreach (string suggestion in SuggestionList)
{
if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
{
suggestionCollection.AppendQuerySuggestion(suggestion);
}
}
}
}
You can add the keyword to SuggestioList, and it will show in the dropdown when you type on the Searchbox.
Create the SuggestionList
public List<string> SuggestionList { get; set; }
initialize the list
SuggestionList = new List<string>();
and add keywords to the list
SuggestionList.Add("suggestion1");
SuggestionList.Add("suggestion2");
SuggestionList.Add("suggestion3");
SuggestionList.Add("suggestion4");
SuggestionList.Add("Fruits");
Thanks.

Categories