2023-09-24 17:26:46 -04:00
|
|
|
|
using System.Windows.Forms;
|
2019-08-27 18:03:21 -04:00
|
|
|
|
using static Vanara.PInvoke.User32;
|
2017-11-27 13:11:20 -05:00
|
|
|
|
|
2023-03-31 11:47:53 -04:00
|
|
|
|
namespace Vanara.Extensions;
|
|
|
|
|
|
|
|
|
|
/// <summary>Extension methods for <see cref="ComboBox"/>.</summary>
|
|
|
|
|
public static partial class ComboBoxExtension
|
2017-11-27 13:11:20 -05:00
|
|
|
|
{
|
2023-03-31 11:47:53 -04:00
|
|
|
|
/// <summary>Sets the text displayed on a <see cref="ComboBox"/> when no item has been selected.</summary>
|
|
|
|
|
/// <param name="cb">The <see cref="ComboBox"/> instance.</param>
|
|
|
|
|
/// <param name="cueBannerText">The cue banner text.</param>
|
|
|
|
|
/// <exception cref="PlatformNotSupportedException">This method is only support on Windows Vista and later.</exception>
|
|
|
|
|
public static void SetCueBanner(this ComboBox cb, string cueBannerText)
|
2017-11-27 13:11:20 -05:00
|
|
|
|
{
|
2023-08-04 12:24:49 -04:00
|
|
|
|
if (Environment.OSVersion.Version.Major >= 6)
|
2017-11-27 13:11:20 -05:00
|
|
|
|
{
|
2023-03-31 11:47:53 -04:00
|
|
|
|
if (!cb.IsHandleCreated) return;
|
|
|
|
|
SendMessage(cb.Handle, (uint)ComboBoxMessage.CB_SETCUEBANNER, IntPtr.Zero, cueBannerText);
|
|
|
|
|
cb.Invalidate();
|
2017-11-27 13:11:20 -05:00
|
|
|
|
}
|
2023-03-31 11:47:53 -04:00
|
|
|
|
else
|
|
|
|
|
throw new PlatformNotSupportedException();
|
2017-11-27 13:11:20 -05:00
|
|
|
|
}
|
|
|
|
|
}
|