FindString in Listview control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Friends,
I am displaying log file in listview control with view
style 'smallIcon'. I want to add search funtionality on it. When user enter
string to search and clicks search button, our funcion should search the list
view data and if string is present, it should highlight that string in list
view. Can anyone help me how to implement this functionality ?

Thanks in advance.

Regards,
-Santosh
 
Having implemented this in the SDF ComboBoxEx class I would imagine the
solution is very similar for the ListView - it's a piece of native
functionality which is not exposed in the .NETCF control. You can take a
look at the ComboBoxEx code from the SDF v1.4 to see how to implement this,
the appropriate LVM_* message identifiers should be already defined in the
OpenNETCF.Win32 namespace (within OpenNETCF.Windows.Forms.dll)

Peter
 
Thanks a lot for the help. Can you please tell me the code link from where I
can download the sample code?

Thanks,
-Santosh
 
Hi Peter,
Thanks. I tried and it's returing the row index for match.

Can you please help me how to highlight that substring of row and how to do
next search starting from first occurence offset ?

Thanks a lot
Santosh
 
Moreover method 'FindStringExact' always return -1 even string is present. I
tested 'ComboBoxEx' code as well and same is happening there. Code snippest
is

public int FindStringExact(string s, int startIndex)
{
int index = -1;
IntPtr pString = MarshalEx.StringToHGlobalUni(s);
index = (int)Win32Window.SendMessage(this.Handle,
(int)CB.FINDSTRINGEXACT, startIndex, pString);
MarshalEx.FreeHGlobal(pString);
return index;
}

FINDSTRINGEXACT = 0x0158,

Any idea will highly appreciated.

Thanks,
-Santosh
 
Back
Top