我有这个小“应用程序”,我希望当有人在自动完成文本框中键入“新”时,它会自动显示“纽约”作为选项,并且(自动完成功能)工作正常。但我希望当用户输入完整位置(或自动完成为他执行此操作)时,该文本(位置)输入将转发到数据库搜索,然后搜索数据库并“收集”具有用户输入位置的所有行。例如,如果用户输入“New York”,数据库搜索将找到其中包含“New York”的所有行。当它找到一行或多行时,它会在下面显示它们。在图像中...
当用户输入时我有这个...
http://www.imagesforme.com/show.php/1093305_SNAG0000.jpg
当用户选择自动完成位置时我有这个
http://www.imagesforme.com/show.php/1093306_SNAG0001.jpg
但当用户选择自动完成位置时我想要这个
http://www.imagesforme.com/show.php/1093307_CopyofSNAG0001.jpg
完整代码
package com.svebee.prijevoz;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
public class ZelimDoci extends Activity {
TextView lista;
static final String[] STANICE = new String[] {
"New York", "Chicago", "Dallas", "Los Angeles"
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.zelimdoci);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, STANICE); …Run Code Online (Sandbox Code Playgroud) 我想创建一个继承自 System.Windows.Forms.TextBox 的新类,并将 keypress 和 keyup 事件分配给我的控件。
像这样的东西:
class CurrencyTextbox : TextBox
{
private void CurrencyTextbox_KeyPress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;
if (!Char.IsDigit(ch) && ch != 8 && ch != 13)
{
e.Handled = true;
}
}
private void CurrencyTextbox_KeyUp(object sender, KeyEventArgs e)
{
if (!string.IsNullOrEmpty(CurrencyTextbox.Text))
{
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
Int64 valueBefore = Int64.Parse(CurrencyTextbox.Text, System.Globalization.NumberStyles.AllowThousands);
CurrencyTextbox.Text = String.Format(culture, "{0:N0}", valueBefore);
CurrencyTextbox.Select(CurrencyTextbox.Text.Length, 0);
}
}
}
Run Code Online (Sandbox Code Playgroud) 如何将字符串值绑定Y到NisEnabled 值?
<TextBox IsEnabled="{Binding Path=StringValueFromSomeEntity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
Run Code Online (Sandbox Code Playgroud)
StringValueFromSomeEntity 可以是一个Y或N值。
我只是想编写一个简单的 javascript 程序,该程序将演示如何从文本字段获取用户输入,然后单击按钮将在另一个文本字段中显示这些数字的求和结果。但不幸的是下面的代码不起作用。单击该按钮不会在结果文本字段中显示任何内容。
<body>
<div>
<div>
<h1>Add two number using text box as input using javascript</h1>
</div>
Enter First Number : <br>
<input type="text" id="Text1" name="TextBox1">
<br>
Enter Second Number : <br>
<input type="text" id="Text2" name="TextBox2">
<br>
Result : <br>
<input type="text" id="txtresult" name="TextBox3">
<br>
<input type="button" name="clickbtn" value="Display Result" onclick="add_number()">
<script type="text/javascript">
function add_number(){
var first_number = parseInt(document.getElementsById("Text1").value);
var second_number = parseInt(document.getElementsById("Text2").value);
var result = first_number + second_number;
document.getElementById("txtresult").innerHTML = result;
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有一个文本框,其中有很多行文本,它的更新如下:
public void UpdateMessageBox(TextBox textBox, string text)
{
textBox.SelectionStart = 0;
textBox.SelectionLength = 0;
textBox.SelectedText = String.Format("{0:HH:mm:ss }", DateTime.Now) + text + "\n";
textBox.ScrollToHome();
}
Run Code Online (Sandbox Code Playgroud)
现在我需要立即从单击鼠标中键的行中获取文本,而不是先通过左键单击选择行。
private void textBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
{
e.MouseDevice.GetPosition(textBox) //what next?
}
}
Run Code Online (Sandbox Code Playgroud)
如何从鼠标位置获取文本框行及其文本?
我想让用户在文本框中输入的文本变为大写。我知道有两种方法可以做到这一点,它们是:
Textbox1.Text = UCase(Textbox1.Text)
or
Textbox1.Text = Textbox1.Text.ToUpper
Run Code Online (Sandbox Code Playgroud)
然而:两者都有相同的问题(当嵌入Textbox1_TextChanged事件处理程序时),即光标不断移回开头,因此如果您慢慢输入,例如 abcdef,它会显示为 FEDCBA。有没有办法在每次将文本变为大写后将光标移回字符串的末尾?
我正在使用 Visual Basic 6 创建一个包含许多名为 txtNo1、txtNo2、txtNo3 的文本框的表...我想使用“For...Next...”循环为这些文本框分配内容。如何以最简单的方式调用所有这些文本框?
For i = 1 to 100
txtNo (......) .txt = "ABC"
Next i
Run Code Online (Sandbox Code Playgroud) 我尝试模仿用户单击用户名字段(例如)时的行为,并且将自动选择所有文本(名称),以便更轻松地用新文本替换它。但是,当用户再次单击该字段时,文本/名称将变为未选中状态,因此用户可以继续从光标写入文本。我确信每个人都知道我想描述什么,因为当我们在文本字段中写入或想要修改其内容时,我们都多次遇到过这种情况......
所以问题是当我使用 Enter focus 事件并应用 SelectAll() 时,根本不起作用!文本仍未选择。我也尝试使用 Click 事件,效果很好,但是第二次单击时遇到了困难,因为所有鼠标单击再次运行 SelectAll() 方法,文本始终仍然处于选中状态。也许我可以使用存储选择状态的全局变量文本和更改状态反之亦然,但如果没有必要,我不想使用任何额外的变量(每个变量都用于所有 TextBox...不)。
应该有一个简单而优雅的解决方案,因为许多应用程序和网站都使用这种行为来使用户的生活更轻松。我阅读了一些论坛并找到了一些解决方案,但它们看起来比我希望的更复杂。
这是我的代码的相关部分......没什么特别的!
private void G_tbx_canvasSize_Enter(object sender, EventArgs e)
{
(sender as TextBox).SelectAll();
}
Run Code Online (Sandbox Code Playgroud)
这应该以这种方式工作:
请帮忙!我不明白为什么会出现这种情况,这不应该发生......
提前致谢!
如何从默认值更改文本框的样式.例如,它看起来像:
替代文字http://www.wiggle100.com/Untitled-2.png
要么
alt text http://www.wiggle100.com/Untitled-3.png
代替:
我正在尝试用C#学习GUI编程,我对C#中TextBox的默认代码有以下问题:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication34
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
// Textbox programming goes here
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我想尝试与TexBox编程有点不同的东西时,类似于这段代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private …Run Code Online (Sandbox Code Playgroud) textbox ×10
c# ×3
winforms ×3
html ×2
wpf ×2
android ×1
autocomplete ×1
binding ×1
click ×1
coordinates ×1
css ×1
events ×1
formatting ×1
forms ×1
function ×1
inheritance ×1
isenabled ×1
javascript ×1
mouseevent ×1
textchanged ×1
uppercase ×1
vb.net ×1
vb6 ×1
wpf-controls ×1