[]
        
(Showing Draft Content)

Using Find and Replace

FlexSheet for WPF allows you to find and replace any text, numbers or information. You can create a Find and Replace dialog box similar to the dialog box shown in the image below:
Find and Replace dialog box

FindRange and FindPriority properties of FindOption class can be used to find and replace any text, numbers or information in FlexSheet. The following code creates the objects of FindOption and C1FlexSheet class and illustrates the use of FindRange and FindPriority properties:

vbnet

Dim _owner As C1FlexSheet
Dim _option As New FindOption(FindRange.Sheet, FindPriority.ByRows, False, False)

csharp

C1FlexSheet _owner;
FindOption _option = new FindOption(FindRange.Sheet, FindPriority.ByRows, false, false);

Find text or numbers

Once you create the objects of FindOption and C1FlexSheet class, you can use the following code to find the text or number you want to search in the FlexSheet:

vbnet

If [String].IsNullOrEmpty(_comboFind.Text) Then
    Return
End If
If Not _comboFind.Items.Contains(_comboFind.Text) Then
    _comboFind.Items.Add(_comboFind.Text)
End If
_owner.FindNext(_comboFind.Text, _option)

csharp

if (String.IsNullOrEmpty(_comboFind.Text))
{
    return;
}
if (!_comboFind.Items.Contains(_comboFind.Text))
    _comboFind.Items.Add(_comboFind.Text);
_owner.FindNext(_comboFind.Text, _option);

Replace text or numbers

You can use the following code to replace the text or number in the FlexSheet:

vbnet

If [String].IsNullOrEmpty(_comboFind.Text) Then
    Return
End If
If Not _comboReplace.Items.Contains(_comboReplace.Text) Then
    _comboReplace.Items.Add(_comboReplace.Text)
End If
Replace(_owner.FindNext(_comboFind.Text, _option))

csharp

if (String.IsNullOrEmpty(_comboFind.Text))
{
    return;
}
if (!_comboReplace.Items.Contains(_comboReplace.Text))
    _comboReplace.Items.Add(_comboReplace.Text);
Replace(_owner.FindNext(_comboFind.Text, _option));

Similarly, you can create code to find all the instances of the searched text or number so that when you find all the matching cells, they are displayed in a result list. You can then replace all the searched data in the result list.