本文介绍了在Dialog中显示列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
i希望在我的应用程序中显示listview项目。
当用户输入ID时在txtbox中按Enter键,想在列表视图中显示结果。
i需要在Dialog中显示列表,如(消息框)
Hi
i want to display listview items in my application .
when the user put ID in the txtbox and press Enter , want to display the result in list view .
i need to display the list in Dialog like ( message box )
推荐答案
using (var f = new FormList(id))
{
if (f.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(f.Result);
}
}
public static DialogResult ShowMe(string title, string promptText, ref string value)
{
//'value' is to return Some value
Form form = new Form();
Label label = new Label();
ListView lv = new ListView();
System.Windows.Forms.Button buttonOk = new System.Windows.Forms.Button();
System.Windows.Forms.Button buttonCancel = new System.Windows.Forms.Button();
form.Text = title;
label.Text = "Some heading";
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
lv.SetBounds(9, 40, 280, 66);
buttonOk.SetBounds(228, 110, 75, 23);
buttonCancel.SetBounds(309, 110, 75, 23);
label.AutoSize = true;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 150);
form.Controls.AddRange(new Control[] { label,lv, buttonOk, buttonCancel });
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
return dialogResult;
}
这篇关于在Dialog中显示列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!