* UIListBox: 增加两个方法

This commit is contained in:
Sunny 2021-08-01 10:57:52 +08:00
parent d7efde59c8
commit 4a108f1db5
10 changed files with 33 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,8 +23,11 @@
UIButton btn; UIButton btn;
private void uiButton1_Click(object sender, System.EventArgs e) private void uiButton1_Click(object sender, System.EventArgs e)
{ {
btn = new UIButton(); btn = new UIButton
btn.Text = "Button" + index++.ToString("D2"); {
Text = "Button" + index++.ToString("D2")
};
//可以用原生方法Controls.Add //可以用原生方法Controls.Add
uiFlowLayoutPanel1.Controls.Add(btn); uiFlowLayoutPanel1.Controls.Add(btn);
//或者封装的方法Add //或者封装的方法Add

View File

@ -166,11 +166,14 @@ namespace Sunny.UI.Demo
private void uiSymbolButton3_Click(object sender, EventArgs e) private void uiSymbolButton3_Click(object sender, EventArgs e)
{ {
UILoginForm frm = new UILoginForm(); UILoginForm frm = new UILoginForm
frm.ShowInTaskbar = true; {
frm.Text = "Login"; ShowInTaskbar = true,
frm.Title = "SunnyUI.Net Login Form"; Text = "Login",
frm.SubText = Version; Title = "SunnyUI.Net Login Form",
SubText = Version
};
frm.OnLogin += Frm_OnLogin; frm.OnLogin += Frm_OnLogin;
frm.LoginImage = UILoginForm.UILoginImage.Login2; frm.LoginImage = UILoginForm.UILoginImage.Login2;
frm.ShowDialog(); frm.ShowDialog();

View File

@ -67,6 +67,16 @@ namespace Sunny.UI
listbox.MouseMove += Listbox_MouseMove; listbox.MouseMove += Listbox_MouseMove;
} }
public int IndexFromPoint(Point p)
{
return listbox.IndexFromPoint(p);
}
public int IndexFromPoint(int x, int y)
{
return listbox.IndexFromPoint(x, y);
}
protected override void AfterSetFillColor(Color color) protected override void AfterSetFillColor(Color color)
{ {
base.AfterSetFillColor(color); base.AfterSetFillColor(color);

View File

@ -77,6 +77,16 @@ namespace Sunny.UI
[Browsable(false)] [Browsable(false)]
public ListBox ListBox => listbox; public ListBox ListBox => listbox;
public int IndexFromPoint(Point p)
{
return listbox.IndexFromPoint(p);
}
public int IndexFromPoint(int x, int y)
{
return listbox.IndexFromPoint(x, y);
}
[DefaultValue(StringAlignment.Near)] [DefaultValue(StringAlignment.Near)]
[Description("列表项高度"), Category("SunnyUI")] [Description("列表项高度"), Category("SunnyUI")]
public new StringAlignment TextAlignment public new StringAlignment TextAlignment
@ -100,7 +110,6 @@ namespace Sunny.UI
get => listbox.SelectedIndices; get => listbox.SelectedIndices;
} }
protected override void OnContextMenuStripChanged(EventArgs e) protected override void OnContextMenuStripChanged(EventArgs e)
{ {
base.OnContextMenuStripChanged(e); base.OnContextMenuStripChanged(e);