C# 实现百度搜索框智能提示功能

用了百度很多年了,发现百度有智能提示功能貌似是在08年的时候。这个功能确实不错,很长一段时间没有发现百度在自己的搜索上提供更实用的功能了。这也勉强算一个吧。

发现了这个功能以后,我相信很多人应该和我一样,总想着用程序去实现他~~嘿嘿。

"用DIV+CSS准没错!"

"一个下拉列表就解决了!"

…………

…………

…………

很多种解决办法。

但是最近一段时间,我又找到了一种更为方便的方法。

在TextBox控件上作文章,设置一下其三种属性就欧克了。哈哈,来看一下吧。

 

一、AutoCompleteSource

      获取或

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
以下是一个简单的C# WinForms程序,实现BLE设备的搜索和数据读写功能。需要使用NuGet包管理器安装`InTheHand.Net.Personal`和`32feet.NET`两个库。 ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using InTheHand.Net; using InTheHand.Net.Bluetooth; using InTheHand.Net.Sockets; namespace BLETest { public partial class Form1 : Form { private BluetoothClient _bluetoothClient = new BluetoothClient(); private BluetoothDeviceInfo _selectedDevice; private BluetoothAddress _selectedAddress; public Form1() { InitializeComponent(); } private void btnSearch_Click(object sender, EventArgs e) { listBox1.Items.Clear(); // 搜索周围的BLE设备 BluetoothDeviceInfo[] devices = _bluetoothClient.DiscoverDevices(255, true, true, false, false); // 将搜索到的设备添加到列表框中 foreach (BluetoothDeviceInfo device in devices) { listBox1.Items.Add(device.DeviceName); } } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { // 获取所选设备的地址 _selectedDevice = _bluetoothClient.GetPairedDevices().FirstOrDefault(d => d.DeviceName == listBox1.SelectedItem.ToString()); _selectedAddress = _selectedDevice.DeviceAddress; btnConnect.Enabled = true; } private void btnConnect_Click(object sender, EventArgs e) { // 连接所选设备 BluetoothClient client = new BluetoothClient(); BluetoothDeviceInfo device = new BluetoothDeviceInfo(_selectedAddress); if (device.InstalledServices.Length > 0) { // 连接到设备 client.Connect(device.DeviceAddress, device.InstalledServices[0].ServiceClass, BluetoothServiceCapabilities.None); // 如果连接成功,则读取设备的数据 if (client.Connected) { try { Stream stream = client.GetStream(); // 读取设备发送的数据 byte[] buffer = new byte[1024]; int count = stream.Read(buffer, 0, buffer.Length); string message = Encoding.ASCII.GetString(buffer, 0, count); // 将数据显示在文本框中 textBox1.Text = message; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } } ``` 在上面的代码中,我们使用`BluetoothClient`类进行BLE设备的搜索和连接,并使用`BluetoothDeviceInfo`类获取设备的信息。在连接成功后,我们通过`GetStream`方法获取设备的数据流,并使用`Read`方法读取设备发送的数据。最后将数据显示在文本框中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值