我有一个TextBox用户可以输入搜索词并ListBox显示结果的。还有一个按钮将根据单击时选择的项目显示一些信息。
我正在尝试使用向上和向下箭头键在列表框中滚动,以便用户不必单击项目,然后单击按钮。那时,我最好还是依靠双击事件来完成工作,因为它们已经在项目上了。但是,我正在尝试使其更加“仅键盘友好”。
以下代码有效,但有一个小缺陷:
private void txtSearchTerm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Down && Results.SelectedIndex < (Results.Items.Count - 1))
{
Results.SelectedIndex++;
}
else if (e.KeyCode == Keys.Up && Results.SelectedIndex > 0)
{
Results.SelectedIndex--;
}
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,光标将随所选项目的更改而左右移动。我希望它保留在原处(而不是强迫它结束)。这次txtSearchTerm.Select(...)活动我没有任何运气,但我想我可能会错过一些事情...
有一个TextChanged事件,但是它仅调用我编写的搜索函数,该函数会在用户键入时填充列表框,因此为简单起见,我将省略该代码。
我是否缺少某些东西或忽略了一些使此TextBox / ListBox组合函数达到预期目的的方法?
快速说明:如果您曾经使用过UltraEdit,则基本上是在尝试模仿该配置窗口的行为。
我有这个方法返回string:
public string SendResponse(HttpListenerRequest request)
{
string result = "";
string key = request.QueryString.GetKey(0);
if (key == "cmd")
{
if (request.QueryString[0] == "uploadstatus")
{
switch (Youtube_Uploader.uploadstatus)
{
case "uploading file":
return "uploading " + Youtube_Uploader.fileuploadpercentages;
case "status":
return Youtube_Uploader.fileuploadpercentages.ToString();
case "file uploaded successfully":
Youtube_Uploader.uploadstatus = "";
return "upload completed," + Youtube_Uploader.fileuploadpercentages + ","
+ Youtube_Uploader.time;
default:
return "upload unknown state";
}
}
if (request.QueryString[0] == "nothing")
{
return "Connection Success";
}
if (request.QueryString[0] == "start")
{
StartRecrod();
result …Run Code Online (Sandbox Code Playgroud) 对于我的登录系统,我希望在我的数据库中散列密码.所以我决定读一下哈希以及怎么做但不幸的是它对我来说没有任何意义,因为我找不到我想要的例子.
我想要它,以便在创建用户帐户时,密码被哈希并存储在我的数据库中,然后当它们登录时,它会哈希登录密码并使用数据库中的哈希密码进行检查.如果这有任何意义,我会很感激帮助.
如果您需要我的代码示例或其他任何问题,我会将其编辑到我的问题中.
我有一个ComboBox我放在SourceGrid3控件中,但由于某种原因我无法设置Enabled属性true.
这是我的代码.
ComboBox cboMyComboBox = new ComboBox();
cboMyComboBox.Enabled = true;
cboMyComboBox.BeginUpdate();
cboMyComboBox.Items.AddRange(new object[] { "Accept", "Reject" });
cboMyComboBox.EndUpdate();
cboMyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
SourceGrid3.Cells.Real.CellControl thisControl = new SourceGrid3.Cells.Real.CellControl(cboMyComboBox);
myGrid[row, column] = thisControl;
Run Code Online (Sandbox Code Playgroud)
(myGrid是SourceGrid3网格)
出于某种原因,当最后一行被执行时,该Enabled值将转向false并且后续尝试更改它(如将其设置回true)不会产生任何影响.
即使我尝试true在Visual Studio调试器中更改值,它也不会允许它,只需将其更改回false.我已经看过了ReadOnly这个字段属性,但似乎并没有成为一个(除非我失去了一些东西),而且我不能改变其他属性(如RightToLeft从No到Yes)
还有什么我可以检查可能会导致这种控制被强制执行false吗?
我已经使用nuget包将costura.fody安装到我的项目中.我已经更新了FodyWeavers.xml文件:
<Costura
Unmanaged32Assemblies='dllname'
Unmanaged64Assemblies='dllname' />
Run Code Online (Sandbox Code Playgroud)
当我重建它并尝试在单独的PC上运行exe而没有dll它不起作用.我错过了什么吗?我还需要添加其他内容吗?我也尝试过以下方法:
<IncludeAssemblies>
dllname
</IncludeAssemblies>
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助.
我有一个10列的DataGridView,当列0可见时,可以说第7,8,9和10列是隐藏的,因为表格有点窄.我可以水平滚动查看第10列,但这会隐藏column0.
在水平滚动时,如何始终保持column0可见?因此滚动条实际上不会扩展到column0.
我正在使用Visual Studio 2013(所以我认为那是.net 5?)
我需要让UI线程等待,直到任务数组完成执行.下面的代码的问题是 - 任务inturn调用UI线程写入文本框.如何解决这个问题?
public partial class FormConsole : Form
{
public FormConsole()
{
InitializeComponent();
}
void txtSayHello_Click(object sender, EventArgs e)
{
Class1 objclss = new Class1();
objclss.formConsole = this;
Task[] taa = new Task[4];
taa[0] = new Task(() => objclss.DoSomeThigs("Hello world"));
taa[1] = new Task(() => objclss.DoSomeThigs("Hello world1"));
taa[2] = new Task(() => objclss.DoSomeThigs("Hello world2"));
taa[3] = new Task(() => objclss.DoSomeThigs("Hello world3"));
foreach(Task task in taa)
{
task.Start();
}
Task.WhenAll(taa);
this.txtConsole.AppendText("All threads complete");
}
delegate void doStuffDelegate(string value);
public void …Run Code Online (Sandbox Code Playgroud) 我试图自动打印一系列Windows窗体.我不需要展示它们.我在互联网上找到的代码示例仅在我显示表单时才有效show()!我需要用数据初始化表单并将其发送到打印机这是我正在使用的代码:
public partial class Form2_withoutShow : Form{
PrintDocument PrintDoc;
Bitmap memImage;
public Form2_withoutShow (Data data)
{
InitializeComponent();
/*
Initialize Data (texboxes, charts ect.) here
*/
this.PrintDoc = new PrintDocument();
this.PrintDoc.PrintPage += PrintDoc_PrintPage;
this.PrintDoc.DefaultPageSettings.Landscape = true;
}
public void Print()
{
this.PrintDoc.Print();
}
void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
int x = SystemInformation.WorkingArea.X;
int y = SystemInformation.WorkingArea.Y;
int width = this.Width;
int height = this.Height;
Rectangle bounds = new Rectangle(x, y, width, height);
Bitmap img = new Bitmap(width, height); …Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio 2013/2015,我的操作系统是Windows 10.我想知道为什么我的WinForms控件看起来如此平坦.我同时启用和禁用了EnableVisualStyles.也许这是一个Windows 10问题?为什么这些控件缺乏3D外观?
非常感谢,
我有一个自定义的控制有两个的PictureBox控件被动画和标签控制他们。
该子指标被设定成标签总是在顶部,但图片框的互换这么活跃,当他们每次显示不同的图像。
据我了解,标签需要有一个父控件,在它上面可以支持半透明颜色(Argb)。由于标签具有活动图片框作为其父标签,因此它也将被动画化,而这根本不是我想要的。
有没有办法确定孩子相对于父母父母的地位?
c# ×10
winforms ×10
.net ×4
async-await ×1
begininvoke ×1
button ×1
combobox ×1
datagridview ×1
fody-costura ×1
hash ×1
listbox ×1
listview ×1
printing ×1
sql ×1
textbox ×1
using ×1
windows-10 ×1