-
Notifications
You must be signed in to change notification settings - Fork 0
search.cs #1
Copy link
Copy link
Open
Description
int index = -1;
bool found = false;
private int Find(string text)
{
int _index;
for (_index = 0; _index < gridAddresses.Rows.Count;_index++)
{
for (var j = 0; j < gridAddresses.Columns.Count; j++)
{
if (gridAddresses[j, _index].FormattedValue.ToString().ToLower().
Contains(text.ToLower().Trim()))
{
found = true;
return _index;
}
}
}
if (found)
{
index = _index;
return _index;
}
else return 0;
}
private int FindNext(string text, int _index)
{
if (index < 0)
{
_index = 0;
}
for (var i = _index+1; i < gridAddresses.Rows.Count; i++)
{
for (var j = 0; j < gridAddresses.Columns.Count; j++)
{
if (gridAddresses[j, i].FormattedValue.ToString().ToLower().
Contains(text.ToLower().Trim()))
{
found = true;
_index = i;
return _index;
}
}
}
if (found)
{
index = _index;
return _index;
}
else
{
index = -1;
return index;
}
}
private void buttonFind_Click(object sender, EventArgs e)
{
if (txtSearch.Text != "")
{
if (index < 0)
{
index = Find(txtSearch.Text);
gridAddresses.CurrentCell = gridAddresses[0, index];
}
else
{
found = false;
index = FindNext(txtSearch.Text, index);
if (index < 0)
{
index = Find(txtSearch.Text);
}
gridAddresses.CurrentCell = gridAddresses[0, index];
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels