本文整理匯總了C#中System.Windows.Forms.TextBoxBase.GetCharIndexFromPosition方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBoxBase.GetCharIndexFromPosition方法的具體用法?C# TextBoxBase.GetCharIndexFromPosition怎麽用?C# TextBoxBase.GetCharIndexFromPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.TextBoxBase
的用法示例。
在下文中一共展示了TextBoxBase.GetCharIndexFromPosition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetCaretIndex
/// <remarks>
/// GetCharIndexFromPosition is missing one caret position, as there is
/// one extra caret position than there are characters (an extra one at
/// the end). See http://stackoverflow.com/a/3874132.
/// </remarks>
public static int GetCaretIndex(TextBoxBase @this, Point point)
{
point = @this.PointToClient(point);
var index = @this.GetCharIndexFromPosition(point);
if (index == (@this.TextLength - 1))
{
var caretPoint = @this.GetPositionFromCharIndex(index);
if (caretPoint.X < point.X) index += 1;
}
return index;
}
開發者ID:njonsson,項目名稱:PasswordTextBox-Control,代碼行數:16,代碼來源:PasswordTextBoxControlTestGuiExtensionMethods-Net20.cs
示例2: GetHotSpotsFromPosition
public ICollection<HotSpotInternal> GetHotSpotsFromPosition(TextBoxBase textBox, Point position) {
int offset = textBox.GetCharIndexFromPosition(position);
return GetHotSpotsFromOffset(offset);
}