How to make interactive labels? - c#

I'm trying to make a small application what will be used as a Template Manager. I would like to ask that how to do that in one user form it will show the data in the following way. Will check .xml file and what is inside tags will be shown one under the other. So lets say I have 5 items with this tag, so all 5 will be listed one under another.
I have something like this, but this is opening a new new MessageBox and showing them one by one.
private void button1_Click(object sender, EventArgs e)
{
string Username = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
var str = Username;
var result = str.Length <= 4 ? "" : str.Substring(4);
string path = $"C:\\Users\\{result}\\Documents
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlTextReader xtr = new XmlTextReader(path);
while (xtr.Read())
{
if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "name")
{
string string_title = xtr.ReadElementString();
// Console.WriteLine("Name = "+ s1);
MessageBox.Show("Title: " + Environment.NewLine + string_title);
}
}
I have a second from called Form2 for now, I can refer in this way as an example new Form2().Show(); but how do I make the lables on the form change according to what is in the xml file between specific tags?

Try this.
string string_title;
while (xtr.Read())
{
if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "name")
{
string_title += xtr.ReadElementString() + Environment.NewLine;
// Console.WriteLine("Name = "+ s1);
}
}
MessageBox.Show("Title: " + string_title);
Guessing if you are calling form 2 from form 1 on the button click. You can do as below.
Inside button click.
var form2 = new Form2(string_title);
form2.show();
Inside form 2.
string dataFromForm1;
public Form2(string data) {
dataFromForm1 = data;
}
Inside form 2 show method.
public void show(){
MessageBox.Show("Title: " + dataFromForm1);
}

Related

How to override a specific line in a text file in c#

I have the following situation. I am creating a quiz game in c# visual studio and want to create a Register and Login forms. When a user registers a new account the text file will store their username and password and will set the high score to 0. Each line in the text file looks like that: username;password;highscore. ';' is the delimiter. I have created a new project to create a practice login/ register form. Here is my code for the register form:
private void btnRegister_Click(object sender, EventArgs e)
{
if (txtPassword.Text == txtConfirmPassword.Text)
{
string newAccount = txtName.Text + ";" + txtConfirmPassword.Text + ";" + "0";
TextWriter account = new StreamWriter("../../TextFile/LogonDetails.txt", true);
account.WriteLine(newAccount);
account.Close();
MessageBox.Show("Account created");
}
and here is my code for the login form
string line = "";
StreamReader myReader = new StreamReader("../../TextFile/LogonDetails.txt");
string[] accounts = new string[900000]; int value = 0;
while ((line=myReader.ReadLine()) != null)
{
string[] data = line.Split(';');
if ((data[0] == txtLoginName.Text) && (data[1] == txtLoginPassword.Text) && (int.Parse(data[2]) > int.Parse(txtScore.Text)))
{
value = 1;
break;
}
if ((data[0] == txtLoginName.Text) && (data[1] == txtLoginPassword.Text) && (int.Parse(data[2]) < int.Parse(txtScore.Text)))
{
value = 2;
break;
}
else
{
value = 3;
}
}
if (value == 1)
{
MessageBox.Show("Your score remains the same");
}
else if (value == 2)
{
string updatedAccount = txtLoginName.Text + ";" + txtLoginPassword.Text + ";" + txtScore;
TextWriter textAccounts = new StreamWriter("../../TextFile/LogonDetails.txt");
textAccounts.WriteLine(updatedAccount);
textAccounts.Close();
}
else if (value == 3)
{
MessageBox.Show("Account not found");
}
}
So my question is how can I override the line stored in the text file if in this case 'txtScore' is greater than data[2]? I have tried creating a new line each time the score is greater but that seems inefficient. Is there a way that i can override the line to change the score value? Any help is greatly appreciated
If the file is not that long you can do something like this:
String fileName = #"C:\LogonDetails.txt";
var data = File
.ReadLines(fileName)
.Select(line => line.Split(';'))
.Select(items => {
if ((items[0] == txtLoginName.Text) &&
(items[1] == txtLoginName.Text) &&
(int.Parse(items[2]) < int.Parse(txtScore.Text)))
items[2] = int.Parse(txtScore.Text);
return items;
})
.ToList(); // materialize in oreder to prevent file read/write collision
File.WriteAllLines(fileName, data);
There is no straightforward way to target a specific line in a text file to update the contents on that line. I would suggest storing your information in an XML (structured data) format; .NET already has the capabilities built in for reading and writing to specific nodes in an XML file.
If you don't want to do that, then my suggestion would be that you load all the lines from the text file into memory as instances of, e.g. a User class that has as properties your username, password, and score, and then write them all back out to your data file all at once with any updates to the scores.
By the way, it's generally not a good idea to store passwords in plain text, so I would hope you're at least employing a hashing algorithm.
Well, based on your question you know the line number, so do something like this:
var lines = File.ReadAllLines(#"path to file");
if (lines.Contains("1234"))
{
lines[Array.IndexOf(lines, "1234")] = "new york";
}
File.WriteAllLines(#"path to file", lines);
try like this.

c# loop all method inside class and assign value

I have a form with all button, label, I plan to make multi-language support by using INI files. I created Lang Class to hold value, if user change language, on-the-fly update without require restart the program.
my current code:
private void LangGet(string LangID)
{
IConfigSource Lng = new IniConfigSource(Globals.Path.FolderLang + "\\" + LangID + ".ini");
// Set
var g = Lng.Configs["general"];
Lang.Id.General.OK = g.GetString("OK");
Lang.Id.General.Cancel = g.GetString("Cancel");
Lang.Id.General.Error = g.GetString("Error");
...
Lang.Id.General.lblStart = g.GetString("lblStart");
...
what I wanted code more efficient, but I dont know how...
IConfigSource Lng = new IniConfigSource(Globals.Path.FolderLang + "\\" + LangID + ".ini");
var g = Lng.Config["general"];
forloop ( ... )
{
item = g.GetString(item);
}
if more powerful
IConfigSource Lng = new IniConfigSource(Globals.Path.FolderLang + "\\" + LangID + ".ini");
forloop ( ... )
{
forloop ( ... )
{
TheName = Lng.Config[TheClass].GetString(TheName);
}
}
After load INI loaded to Variable, time to control text get Variable value
forloop ( control )
{
forloop ( class )
{
if ( control name contain btn )
{
item.Text = Lng.Configs[TheClass].GetString(item.name?);
}
if ( control name contain lbl )
{
item.Text = Lng.Configs[TheClass].GetString(item.name?);
}
// So On...
I found my answer... so I answer my self,
using Ini-parser instead of Nini...
Make multi-language using INI file, allow language to be edited after compiled, easy to do correction.
Instead write code every control, use loop to do their job
CreateLang(); will scan all your form and it's child, using control Name as Ini Key
LoadLang(); will scan all your form control, once Ini Key equal control name, Value will apply to control.
During designing, all control must be change to {0} or multi-line {0}{1}{2}
Code:
private void frmMain_Load(object sender, EventArgs e)
{
CreateLang(); // Create new empty language
//LoadLang(); // Load language, GUI must use {0} {1} ... as place-holder
}
private void LoadLang()
{
var parser = new FileIniDataParser();
IniData data = parser.ReadFile("eng.ini");
Control ctrl = this;
do
{
ctrl = this.GetNextControl(ctrl, true);
if (ctrl != null)
if (ctrl is Label ||
ctrl is Button ||
ctrl is TabPage ||
ctrl is CheckBox)
if (data["Root"][ctrl.Name].Contains('|')) // Character | donated by New-Line, \n
ctrl.Text = String.Format(ctrl.Text, data["Root"][ctrl.Name].Split('|'));
else
ctrl.Text = String.Format(ctrl.Text, data["Root"][ctrl.Name]);
} while (ctrl != null);
}
private void CreateLang()
{
if (System.IO.File.Exists("eng.ini"))
System.IO.File.WriteAllText("eng.ini", "");
else
System.IO.File.WriteAllText("eng.ini", "");
var parser = new FileIniDataParser();
IniData data = parser.ReadFile("eng.ini");
data.Sections.AddSection("Info");
data.Sections["Info"].AddKey("Name", "Anime4000");
data.Sections["Info"].AddKey("Version", "0.1");
data.Sections["Info"].AddKey("Contact", "fb.com/anime4000");
string main = "Root";
data.Sections.AddSection(main);
Control ctrl = this;
do
{
ctrl = this.GetNextControl(ctrl, true);
if (ctrl != null)
if (ctrl is Label ||
ctrl is Button ||
ctrl is TabPage ||
ctrl is CheckBox ||
ctrl is GroupBox)
data.Sections[main].AddKey(ctrl.Name, "");
} while (ctrl != null);
parser.WriteFile("eng.ini", data);
}

C# Reader Text File, Search for String, Overwrite Line

I'm attempting to read a text file if it exists and then search for a specific string at the beginning of each line. If it exists, I want to overwrite that line with newly input variables. I'm getting an error when the Enter/Update Player button is clicked. I've noted in the code where the error occurs.
The error I receive:
"The process cannot access the file because it is being
used by another process. "
I'm assuming this is related to StreamReader/StreamWriter interference, but I can't figure out where the error is coming from. Any help would be greatly appreciated!
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Text;
using System.Windows.Forms;
namespace Namespace1
{
public partial class FormPokerStats : Form // FormPokerStats inheriting from class Form
{
// declaring and assigning of variables needed for file read/write
const char DELIM = ',';
const string FILEPATH = #"C:\C# Project Output\";
const string FILENAME = "PokerPlayers.txt";
// declaring instances of Person, Location, and Winnings classes
Location mycasino = new Location();
Winnings mywinnings = new Winnings();
public delegate void Total(double[] total);
// constructing in/out FileStream/StreamReader/StreamWriter objects
static FileStream inFile = new FileStream(FILEPATH + FILENAME, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
StreamWriter writer = new StreamWriter(outFile);
static FileStream outFile = new FileStream(FILEPATH + FILENAME, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
StreamReader reader = new StreamReader(inFile);
public FormPokerStats()
{
InitializeComponent();
}
// "Enter/Update Player" tab Enter Player button: read/assign user input, write to file, close file stream
private void buttonEnterPlayer_Click(object sender, EventArgs e)
{
Player myplayer = null;
// if directory does not exist, create it
if (!(Directory.Exists(FILEPATH)))
{
// create directory
Directory.CreateDirectory(FILEPATH);
}
try
{
// read user input and assign to variables; test for empty player inputs and reprompt for input, if necessary
// Player Information fields
// if any or all textboxes are left blank
if ((maskedTextBoxSSN.Text == String.Empty || textBoxFirstName.Text == String.Empty || textBoxLastName.Text == String.Empty
|| textBoxCasinoName.Text == String.Empty || textBoxCasinoState.Text == String.Empty) ||
(maskedTextBoxSSN.Text == String.Empty && textBoxFirstName.Text == String.Empty && textBoxLastName.Text == String.Empty
&& textBoxCasinoName.Text == String.Empty && textBoxCasinoState.Text == String.Empty))
{
MessageBox.Show("Please complete all player information fields.", "Input Error!");
}
else
{
// if all textboxes are completed, assign to variables
myplayer = new Player(maskedTextBoxSSN.Text, textBoxFirstName.Text, textBoxLastName.Text);
mycasino.CasinoName = textBoxCasinoName.Text;
mycasino.CasinoState = textBoxCasinoState.Text;
}
// read weekly winnings input and assign to appropriate array position; test for empty inputs and assign default value of 0 if empty
// Week1
if (textBoxWeek1Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(0, 0);
}
else mywinnings.AddNewWinnings(0, Convert.ToDouble(textBoxWeek1Winnings.Text));
// Week2
if (textBoxWeek2Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(1, 0);
}
else mywinnings.AddNewWinnings(1, Convert.ToDouble(textBoxWeek2Winnings.Text));
// Week3
if (textBoxWeek3Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(2, 0);
}
else mywinnings.AddNewWinnings(2, Convert.ToDouble(textBoxWeek3Winnings.Text));
// Week4
if (textBoxWeek4Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(3, 0);
}
else mywinnings.AddNewWinnings(3, Convert.ToDouble(textBoxWeek4Winnings.Text));
// Week5
if (textBoxWeek5Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(4, 0);
}
else mywinnings.AddNewWinnings(4, Convert.ToDouble(textBoxWeek5Winnings.Text));
// Week6
if (textBoxWeek6Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(5, 0);
}
else mywinnings.AddNewWinnings(5, Convert.ToDouble(textBoxWeek6Winnings.Text));
// Week7
if (textBoxWeek7Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(6, 0);
}
else mywinnings.AddNewWinnings(6, Convert.ToDouble(textBoxWeek7Winnings.Text));
// Week8
if (textBoxWeek8Winnings.Text == String.Empty)
{
mywinnings.AddNewWinnings(7, 0);
}
else mywinnings.AddNewWinnings(7, Convert.ToDouble(textBoxWeek8Winnings.Text));
// calculate total winnings by summing WeeklyWinnings array values and assigning to TotalWinnings
Total pointer = null;
pointer += new Total(mywinnings.compileTotal);
pointer(mywinnings.WeeklyWinnings);
///////////////////////////////////ERROR HERE////////////////////////////////////
// check file for input SSN; if exists, overwrite that record and rewrite to file
if (!(File.Exists(FILEPATH + FILENAME)))
{
List<string> lines = new List<string>(File.ReadAllLines(FILEPATH + FILENAME));
int lineIndex = lines.FindIndex(line => line.StartsWith(myplayer.SocialSecurityNumber));
if (lineIndex != -1)
{
lines[lineIndex] = myplayer.ToString() + mycasino.ToString() + mywinnings.ToString();
File.WriteAllLines(FILEPATH + FILENAME, lines);
}
else
{
// writing record to text file
writer.WriteLine(myplayer.ToString() + mycasino.ToString() + mywinnings.ToString());
}
}
// if record is successfully written, display messagebox
MessageBox.Show("Wrote " + myplayer.FirstName.ToString() + ' ' + myplayer.LastName.ToString() + " to file with winnings totaling " + mywinnings.TotalWinnings.ToString("C2") + ".", "File Written");
}
catch (FormatException)
{
// if format exception is thrown in try, display messagebox with message
MessageBox.Show("Winnings must be entered at xx.xx (e.g. 34.56).", "Input Error!");
}
catch (Exception f)
{
// if exception is thrown in try, display messagebox with message
MessageBox.Show(f.Message, "Error!");
}
// clear form textboxes
ClearTextBoxes();
maskedTextBoxSSN.Clear();
writer.Close();
}
// "Enter/Update Player" tab Exit button: closes file streams and quits the application
private void buttonExit_Click(object sender, EventArgs e)
{
// closing file streams
reader.Close();
inFile.Close();
writer.Close();
outFile.Close();
// close application
Application.Exit();
}
// "Player List" tab View Player Winnings button: read file records, display records sorted by total winnings descending
private void buttonRead_Click(object sender, EventArgs e)
{
// clear listbox items
listBoxOutputRecords.Items.Clear();
// if file exists
if (!(File.Exists(FILEPATH + FILENAME)))
{
// if file does not exist, display messagebox
MessageBox.Show("File does not exist.", "File Does Not Exist!");
}
else
{
string[] fields;
// output header row labels to listbox
listBoxOutputRecords.Items.Add("First Name\tLast Name\tCasino Name\tCasino State\tTotal Winnings\t");
// read first record in file
string recordIn = reader.ReadLine();
// instantiate an instance of playerList list of tuples
List<Tuple<string, string, string, string, double>> playerList = new List<Tuple<string, string, string, string, double>>();
// loop through text file records until last record is reached
while (recordIn != null)
{
// split record into array and assign
fields = recordIn.Split(DELIM);
Player myplayer = new Player(fields[0], fields[1], fields[2]);
mycasino.CasinoName = fields[3];
mycasino.CasinoState = fields[4];
mywinnings.TotalWinnings = Convert.ToDouble(fields[13]);
// add player to the playerList list of tuples
playerList.Add(new Tuple<string, string, string, string, double>(myplayer.FirstName, myplayer.LastName, mycasino.CasinoName, mycasino.CasinoState, mywinnings.TotalWinnings));
// read next record in file
recordIn = reader.ReadLine();
}
// sort playerList list of tuples by total winnings descending
playerList.Sort((a, b) => b.Item5.CompareTo(a.Item5));
// display each record of the playerList list of tuples in the listbox
foreach (var element in playerList)
{
listBoxOutputRecords.Items.Add(element.Item1 + "\t\t" + element.Item2 + "\t\t" + element.Item3 + "\t\t" + element.Item4 + "\t\t" + element.Item5.ToString("C2"));
}
}
// return file position to 0
inFile.Seek(0, SeekOrigin.Begin);
}
// "Player List" tab Exit button: call buttonExit_Click method
private void buttonExit2_Click(object sender, EventArgs e)
{
// call buttonExit_Click method
buttonExit_Click(sender, e);
}
// method to clear listbox items when "Player List" tab is left
private void tabPagePlayerList_Leave(object sender, EventArgs e)
{
// clear listbox items
listBoxOutputRecords.Items.Clear();
}
// method to clear textbox controls
private void ClearTextBoxes()
{
Action<Control.ControlCollection> func = null;
func = (controls) =>
{
foreach (Control control in controls)
if (control is TextBox)
(control as TextBox).Clear();
else
func(control.Controls);
};
func(Controls);
}
}
As I can see, you're closing all the streams on existing the application. You need to close the streams as soon as you have used them. For example, once you have read the file contents to reader, you can close file stream. Similarly, when you have moved the reader stream to writer stream, you need to close the reader stream right away.
Your above error is surely occurring due to some open stream. So to make sure file is not somehow being accessed by another process, just close your streams as soon as they're used. Try this and if further help required, do share.

Click item in listbox and View details in multiline textbox

I would like to click on an item in a listbox and display the attributes that were passed into that listbox to a multiline textbox.
Below is the code I have written on form initialisation
public Form1()
{
InitializeComponent();
ReadFromFile.Read("sample.GED");
foreach (KeyValuePair<int, Individual> kvp in ReadFromFile.individuals)
{
listBox2.Items.Add("ID = " + kvp.Value.id + " Name = " + kvp.Value.name.givenName + " " + kvp.Value.name.surname + " DoB = " + kvp.Value.birth.date);
}
int testIndividual = 94;
string genderOut = "";
if (ReadFromFile.individuals[testIndividual].gender == "M")
{
genderOut = "MALE";
}
else if (ReadFromFile.individuals[testIndividual].gender == "F")
{
genderOut = "FEMALE";
}
try
{
textBox1.AppendText(
"Name = " + ReadFromFile.individuals[testIndividual].name.givenName + " "
+ ReadFromFile.individuals[testIndividual].name.surname
+ Environment.NewLine + "Gender = " + genderOut
+ Environment.NewLine + "Birth date = " + ReadFromFile.individuals[testIndividual].birth.date
+ Environment.NewLine + "Birth place = " + ReadFromFile.individuals[testIndividual].birth.place
+ Environment.NewLine + "Death date = " + ReadFromFile.individuals[testIndividual].death.date
+ Environment.NewLine + "Death place = " + ReadFromFile.individuals[testIndividual].death.place);
}
catch
{
MessageBox.Show("This individual doesnt exist");
}
}
}
I would like to add more so I can click on a listbox item and the details for that item will be shown in the textbox
I get the feeling I may have to override the ToString() method or regex it. Im still quite a novice programmer so go easy on me :) THANK YOU
You need to handle the SelectedIndexChanged event for your listbox.
One way to do this is to bring up Form1.cs[Design] and select the listbox. In the property grid (Alt+Enter) click the icon that looks like this:
Find the event SelectedIndexChanged and double click it. That will hook up an event handler for you in the auto generated Form1.cs.designer file.
Next, replace the code for your Form1 class with the following:
public partial class Form1 : Form
{
private Dictionary<int, Individual> _individuals;
public Form1()
{
InitializeComponent();
ReadFromFile.Read("sample.GED");
_individuals = ReadFromFile.individuals;
listBox1.DataSource = _individuals.Select(individual => individual.Value).ToList();
listBox1.DisplayMember = "name";
listBox1.ValueMember = "id";
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Clear();
var individual = listBox1.SelectedItem as Individual;
string genderOut = (individual.Gender == "M") ? "MALE" : "FEMALE";
var displayText
= String.Format("Name = {0} {1}\r\n" +
"Gender = {2}\r\n" +
"Birth date = {3}\r\n" +
"Birth place = {4}\r\n" +
"Death date = {5}\r\n" +
"Death place = {6}"
, individual.name.givenName
, individual.name.surname
, genderOut
, individual.birth.date
, individual.birth.place
, individual.death.date
, individual.death.place);
textBox1.AppendText(displayText);
}
}
A few notes about some of the things i've changed.
I've moved the code that was setting the textbox value into the SelectedIndexChanged event handler
I've refactored that code so that it's more readable by using the static String.Format method (all those Environment.NewLine repeats you had were messy).
I've setup the data for the list box using the DataSource property instead of your foreach loop.
Also, one thing you'll notice with this is that the list items in the listbox will not show the correct text. This is because you appear to be using some custom classes or structs for the name, birth and death of an Individual? To fix this, you need to add a new property to the Individual class like this:
public class Individual
{
// ... your code
public string DisplayName
{
get { return String.Format("{0} {1}), name.givenName, name.surname; }
}
// ... the rest of your code
}
Then you will need to change the line in my code above that looks like this:
listBox1.DisplayMember = "name";
to this:
listBox1.DisplayMember = "DisplayName";
Final note: You should probably be using "Upper Camel Case" for your property names. That means that they start with an upper case letter and then the first letter of each word is also upper case. For example, name.givenName should be Name.GivenName. This is a widely used convention.

Implementing "Find Next" in web browser control in C#

I have a web browser control embedded in a form. Upon form load it loads a locally stored HTML file. I have implemented a find text functionality to find a particular text in the HTML document loaded in the web browser control. It is working for finding the first occurrence of the word specified.But I want to highlight all the occurrences of the specified word all at once or still better implementing something analogous to "Find Next" function found in various applications. Is it possible to do that for web browser control???
Here's the current code:
private void toolStripButton1_Click(object sender, EventArgs e)
{
string TextToFind;
TextToFind = toolStripTextBox1.Text;
if (webBrowser1.Document != null)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
if (doc != null)
{
IHTMLSelectionObject currentSelection = doc.selection;
IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
if (range != null)
{
String search = TextToFind.ToString();
if (range.findText(search, search.Length, 2))
{
range.select();
}
}
}
}
}
Thanks.
You will find the the code sample for your question here MSDN Forums: WebBrowser Find Dialog
Hope that is exactly what you are looking for.
Just take input from the user in a textbox [here txtNoteSearch] and then follow the following code to implement the search. Following code demonstrates the search and highlight.
private void WebBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
mshtml.IHTMLDocument2 doc2 = WebBrowser.Document.DomDocument;
string ReplacementTag = "<span style='background-color: rgb(255, 255, 0);'>";
StringBuilder strBuilder = new StringBuilder(doc2.body.outerHTML);
string HTMLString = strBuilder.ToString();
if (this.m_NoteType == ExtractionNoteType.SearchResult)
{
List<string> SearchWords = new List<string>();
SearchWords.AddRange(this.txtNoteSearch.Text.Trim.Split(" "));
foreach (string item in SearchWords)
{
int index = HTMLString.IndexOf(item, 0, StringComparison.InvariantCultureIgnoreCase);
// 'If index > 0 Then
while ((index > 0 && index < HTMLString.Length))
{
HTMLString = HTMLString.Insert(index, ReplacementTag);
HTMLString = HTMLString.Insert(index + item.Length + ReplacementTag.Length, "</span>");
index = HTMLString.IndexOf(item, index + item.Length + ReplacementTag.Length + 7, StringComparison.InvariantCultureIgnoreCase);
}
}
}
else
{
}
doc2.body.innerHTML = HTMLString;
}

Categories

Resources