- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在文本最后一个字符的正下方显示一个类似智能感知的小窗口(它是一个小窗体),但在我当前的代码中,它的坐标似乎是随机的并且不是很准确。我们将不胜感激。
当我按下 Alt+1(在输入时显示类似智能的窗口,我调用这段代码:
shortcuts.Location = GetPoint((TextBox)tabControl1.SelectedTab.Controls[0]);
shortcuts.Show(this);
获取坐标的coed是:
private Point GetPoint(TextBox textBoxControl)
{
Graphics graphics = Graphics.FromHwnd(textBoxControl.Handle);
SizeF size = graphics.MeasureString(textBoxControl.Text.Substring(0,
textBoxControl.SelectionStart), textBoxControl.Font);
Point coord = new Point((int)size.Width + textBoxControl.Location.X,
(int)size.Height + 200 + textBoxControl.Location.Y);
return coord;
}
我承认可能有更好的方法,但这对我来说非常有效:
private Point GetPoint(TextBox textBoxControl)
{
Graphics graphics = Graphics.FromHwnd(textBoxControl.Handle);
SizeF size = graphics.MeasureString(textBoxControl.Text.Substring(0,
textBoxControl.SelectionStart), textBoxControl.Font);
Point coord = new Point(this.Left + (int)size.Width + textBoxControl.Location.X + 5,
this.Location.Y + 25 + toolStrip1.Height + tabControl1.Top + (int)size.Height + tabControl1.Top + textBoxControl.Location.Y + 25);
return coord;
}
然而,由于某种原因,第一次调用此方法时,它总是出现在某个随机位置——尽管每次对该方法的后续调用都会导致窗口被放置在它应该放置的位置;就在当前文本行的下方并水平对齐,这样窗口就在文本框中的最后一个字符之后。
最佳答案
试试这个:
TextBox tb = (TextBox)tabControl1.SelectedTab.Controls[0];
Point thePoint = GetPoint(tb);
shortcuts.Location = tb.PointToClient(tabControl1.PointToScreen(thePoint)); //assuming "this" is the form itself
在 GetPoint() 方法中,将“200 +”替换为 tabControl1.GetTabRect(0).Height。我还必须添加 5 作为 X 和 Y 的填充,因为 tabControl 有一些间距。
关于c# - 打字时显示类似 Intellisense 的窗口(无法获得正确的坐标),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16835763/
如何使用打字模块来创建可以是某些字符串的类型? 例如。假设我需要一个类型 CondOperator ,可以是以下任何字符串: ['=', '>', '=', '', '!='] 我希望 CondOpe
我目前正在从事一个处理语言学习(即德语、中文等...)的项目,其中有一个功能我们遇到了问题 - 简而言之,我们正在尝试显示“幽灵” "文本(非常淡的灰色)并允许用户键入覆盖此文本。 该项目将有数千个不
typing 模块提供了一些方便的功能,以实现更好的可读性和对键入代码正确性的信心。 最好的功能之一是您可以编写如下内容来描述具有指定元素类型的输入字典。 def myFun(inputDict:Di
我想创建一个 Array 类型,它应该是可订阅 并且是 typing.List 和 numpy 的联合体.ndarray 类型。我知道 numpy 没有 stub ,但是 those numpy st
我想写一个groupBy功能,到目前为止,类型系统对我的工作不太满意。 export function group( data: T[], groupBy: keyof T ): {
我正在努力解决打字问题并提出以下问题 您在项目的 node_modules 根文件夹下找到的 typings 文件夹是什么。这是 tsc 查找 .d.ts 文件的默认位置吗?我如何在源文件中使用它们。
在打字时使用 typing.Any 和 object 有什么区别吗?例如: def get_item(L: list, i: int) -> typing.Any: return L[i] 相
我刚开始使用 TypeScript,所以请记住。我正在尝试在 React/TS 中实现一个简单的文件上传。一般来说,我认为我不明白如何初始化对象,比如在 useState 中,并正确处理可能性。例如,
我想这是python 3.7(不确定)附带的,不仅可以将变量名传递给函数,还可以传递变量的类型。我想知道的是是否有可能传递特定类的类型。 你可以通过同样的方式: def foo_func(i: int
有没有办法在 TypeScript 类中拥有动态对象属性,并为 TypeScript 添加动态类型? 我见过类似的问题,但没有一个像这样的完整示例 - interface IHasObjectName
我正在尝试将类型添加到一些数字 Racket 代码中,希望能使其更快,但我在下面的代码中遇到了 for/list 宏扩展的问题。 (: index-member ((Listof Any) (List
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 提供事实和引用来回答它. 2年前关闭。 Improve this
我在 Scala 中有一个打字问题的小问题。在 Haskell 中,我可以这样做: add :: (Num a) => (a,a) -> (a,a) -> (a,a) 这样,我就可以扔进add任何支持
我想实现这个。 当文本表单字段处于非事件状态时,其背景和填充颜色将为灰色。但是当我打字或它处于事件模式时,它的背景颜色将为白色。 如何实现这种行为? 最佳答案 试试这个: class CustomTe
我想实现这个。 当文本表单字段处于非事件状态时,其背景和填充颜色将为灰色。但是当我打字或它处于事件模式时,它的背景颜色将为白色。 如何实现这种行为? 最佳答案 试试这个: class CustomTe
这可以模拟击键: import pyautogui pyautogui.typewrite('hello world!', interval=0.1) 除了: 它写的是 hello world§(使用
我正在寻找 python 中的东西因为它是动态类型而更容易编程的例子? 我想将它与 Haskell 类型系统进行比较,因为它的静态类型不像 c# 或 java 那样妨碍。我可以像在 python 中一
当运行 typings 命令时,我总是得到错误: AppData\Roaming\npm\node_modules\typings\node_modules\strip-bom\index.js:2
我正在学习 Ruby,我遇到了一个关于打字的主要概念问题。请允许我详细说明为什么我不理解范式。 假设我像您在 Ruby 中一样为简洁的代码进行方法链接。我必须准确地知道链中每个方法调用的返回类型是什么
只是关于打字的快速问题。 如果我输入 ghci :t [("a",3)]我回来了[("a",3)] :: Num t => [([Char], t)] 在文件中,我将类型定义为: type list
我是一名优秀的程序员,十分优秀!