Filter SelectBluetoothDeviceDialog

Topics: Bluetooth - Microsoft
Feb 2, 2012 at 5:18 AM

Hello I'm German user, and I like to Filter the SelectBluetoothDeviceDialog function so that devices displayed with the name TESTit a other possibility would that devices form type other is displayed

(sorry for my bad English)

Feb 5, 2012 at 7:50 PM

That's not something we support currently.  It should be possible to add that into the source code.  We'd accept a patch. :-)  Apart from that I'm afraid that you'll have to create your own dialog. :-(

Feb 23, 2012 at 12:50 PM
Edited Feb 23, 2012 at 12:52 PM

I'd like to create a own Dialoge because I have problems with finding all Devices with the Disvovery Function, with SelectBluetoothDeviceDialog I have no Problem but there is the Problem with filter. I think I use SelectBluetoothDeviceDialog that find everything. With the Source Code I have experimented with no result.

Feb 27, 2012 at 3:00 PM

I've had a look at the code for the dialog (both for MSFT+Win32 and the code for all the other platforms) and it should be possible to add a filter function to it.  I have paying projects at the 'front of the queue' at the moment so I'll get back to this sometime, hopefully not to far away...

Mar 6, 2012 at 7:19 AM

Thats good news, but my Project should be complete in 2 weeks, can you give me the place and a example to fix the Source code, that the Dialog show only Devices with the name TESTit or BAmobile

Mar 8, 2012 at 3:18 PM
Edited Mar 8, 2012 at 3:19 PM

bug 32382 "Provide callback on SelectBluetoothDeviceDialog to allow filtering of devices"  

Fixed in r96648. Please download, compile and let me know if it does what you want. :-)











dlg = new InTheHand.Windows.Forms.SelectBluetoothDeviceDialog();
    dlg.DeviceFilter = FilterDevice;
    var rslt = dlg.ShowDialog();

FilterDevice(BluetoothDeviceInfo dev)

     var ret = true;
     ret = console.ReadYesNo(
"Include this device " + dev.DeviceAddress + " " + dev.DeviceName, ret);  
     return ret;




Mar 9, 2012 at 6:35 AM
Edited Mar 9, 2012 at 12:17 PM

Its better to filter the Devices by name, I have many Devices the the same name. With your filter function you can only filter one Device and you need the Device adress to create a new deviceInfo. I'd like that the Dialog display all devices with the name TESTit or BAmobile and Divices with other names are not displayed.

I thank you in front for your work

Mar 9, 2012 at 4:29 PM

I'm not sure I'm understanding fully.  So...

The callback method is called for each device as it is being added to the dialog box.  If the function returns false it won't be added, otherwise it will be added and displayed. The information about the device is provided as a BluetoothDeviceInfo instance which will contain all the information about the device that the discovery process knows and will also include any information from remembered/authenticated/paired devices. Note that prior to Bluetooth v2.1 a separate query has to be carried out to find whether the device also has a name, so unless both devices are v2.1 or later then its likely that the name won't be included in the first discovery. 

Does that help at all?

Mar 12, 2012 at 1:29 PM

I understand what you say, but I  don't get the Function to work. Can you give me a example in I have convert your code to and it says parameter not set and a error code with the return value and other error messages



  dlg.DeviceFilter = FilterDevice() ' error message
        Dim result As DialogResult = dlg.ShowDialog(frmTestIt) 

Function FilterDevice(dev As BluetoothDeviceInfo) As Boolean
        Dim ret as boolean = true
        Return ret
    End Function

Mar 13, 2012 at 2:02 PM

You need to add the AddressOf keyword to tell VB to use the FIlterDevice function as a delegate (e.g. callback method).


    Dim dlg As New InTheHand.Windows.Forms.SelectBluetoothDeviceDialog()
    dlg.DeviceFilter = AddressOf FilterDevice
    Dim rslt As DialogResult = dlg.ShowDialog()

Shared Function FilterDevice(ByVal dev As BluetoothDeviceInfo) As Boolean
    Dim rslt As DialogResult = MessageBox.Show("Include this device " & dev.DeviceAddress.ToString & " " & dev.DeviceName, "FilterDevice", MessageBoxButtons.YesNo)
    Dim ret As Boolean = (DialogResult.Yes = rslt)
    Return ret
End Function

Mar 14, 2012 at 6:14 AM

Thank you, it works correctly

Mar 18, 2012 at 5:15 PM