我的表单有文本框,其中包含数量的数字.然后在textchanged事件中,该号码被放置在具有货币值的标签的文本属性中(例如:$ 4.00).在我的按钮单击事件中,我试图添加标签中的所有值.使用以下代码时,tryparse每次都会失败
int num1;
string text = lbl85x11bwsub.Text;
if (int.TryParse(text, out num1))
{
MessageBox.Show(num1.ToString()); //testing
}
else
{
MessageBox.Show("it failed");
}
Run Code Online (Sandbox Code Playgroud)
但如果我使用文本框的文本属性尝试相同的东西,它的工作原理.
int num2;
if (int.TryParse(txt85x11bw.Text, out num2))
{
MessageBox.Show(num2.ToString());
}
else
{
MessageBox.Show("it failed");
}
Run Code Online (Sandbox Code Playgroud) Visual Studio 2012,Asp.net,webforms.
尝试将输入控制到文本框中,仅限数字.我有以下代码:
<asp:RegularExpressionValidator id="RegularExpressionValidator1"
ControlToValidate="txtAcres"
ValidationExpression="^\d+"
Display="Static"
ErrorMessage="Only Numbers"
EnableClientScript="False"
runat="server"></asp:RegularExpressionValidator>
Run Code Online (Sandbox Code Playgroud)
但我可以输入任何文字.我错过了什么?
我是Android开发的新手,我已下载Android SDK 4.2并收到错误:
Could not execute build using Gradle distribution 'http://services.gradle.org /distributions/gradle-1.9-all.zip'. from the event log
Run Code Online (Sandbox Code Playgroud)
我在这里尝试了许多类似的错误消息的解决方案:
文件 - 使高速缓存无效/重新启动 - 无效并重新启动.然后关闭AS并将c/users/myname中的.gradle文件夹重命名为old.gradle并重新启动.
将build.gradle com.android.tools.build:gradle:0.7.+'中的版本号重命名为0.8.+
将gradle-wrapper.properties services.gradle.org/distributions/gradle-1.9-all.zip中的版本重命名为1.10
卸载AS两次.
我简单无法理解的一些解决方案,对于那些我理解的解决方案,似乎我已经尝试了所有这些解决方案.
我读过尝试另一个版本的gradle 1.9,但不要从哪里开始.有没有像1.9.1,1.9.2..etc这样的版本?
有帮助吗?
的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Run Code Online (Sandbox Code Playgroud)
gradle-wrapper.properties:
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
Run Code Online (Sandbox Code Playgroud) 使用autolayout我无法在代码中覆盖我的标签.我在IB中设置了标签属性:Lines = 0,LineBreaks = Word Wrap,但我将我的高度设置为单行,因为选择了哪个单元格确定标签中的文本.所以有时标签只有一行.
在我的viewDidLoad中:
myLabel.text = @”blah, blah, blah….”;
[myLabel setLineBreakMode:NSLineBreakByWordWrapping];
myLabel.numberOfLines = 0; //have tried 1 but didn’t help
[myLabel sizeToFit];
Run Code Online (Sandbox Code Playgroud)
这适用于另一个项目,但我没有使用AutoLayout.AutoLayout似乎覆盖了这些设置.
我甚至补充道
[myLabel setFrame:CGRectMake(20, 135, 280, 80);
Run Code Online (Sandbox Code Playgroud)
但它没有帮助.
我有一个带有标签和文本框的 div,我只是想让文本框伸展以填充页面上的剩余空间。我知道 100% 宽度不包含任何填充或边距值,因此我已将其添加到文本框和 div。我搜索了许多类似的主题,但我的文本框总是放到标签下方的新行。我错过了什么?我将我的 css 内联放置只是为了测试目的。
<div style="padding-right:10px;">
<asp:Label ID="Label1" runat="server" Text="Label" style="float:left; width:150px; display:inline-block"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" style="display:inline-block; width:100%; padding-right:0"></asp:TextBox>
</div>
Run Code Online (Sandbox Code Playgroud) Windows窗体:有没有办法说如果以下所有条件都是真的那么'执行此操作',否则"执行此操作"?我的表单有多个文本框,其中至少有一个需要输入内容.我下面的代码检查空文本框,但如果任何文本框为空,则将条件设置为false.
private void cmdEnter_Click(object sender, EventArgs e)
{
bool allempty = true;
foreach (Control d in Controls)
{
if (d is TextBox)
{
TextBox textbox = d as TextBox;
if (textbox.Text == string.Empty)
{
allempty = false;
}
}
}
if (allempty == false)
{
MessageBox.Show("Textboxes are all empty");
}
else
{
//Data entry code
MessageBox.Show("Entry Added");
}
}
Run Code Online (Sandbox Code Playgroud)