我有一个文字输入.当输入获得焦点时,我想选择输入内的文本.
使用jQuery我会这样做:
<input type="text" value="test" />
Run Code Online (Sandbox Code Playgroud)
$("input[type=text]").click(function() {
$(this).select();
// would select "test" in this example
});
Run Code Online (Sandbox Code Playgroud)
我一直在寻找尝试找到Angular的方法,但我发现的大多数例子都是在处理一个正在观察变化的模态属性的指令.我假设我需要一个正在观察获得焦点的输入的指令.我该怎么办?
我在MapView上显示用户头像图像.如果在没有动画的情况下渲染它们,它们似乎正在工作,但是我想为它们的动画制作动画.如果我将pinView.animatesDrop设置为true,那么我将丢失头像并将其替换为pin.如何在不使用针的情况下为我的头像添加动画效果?
这是我正在使用的viewForAnnotation方法:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView* pinView = (MKPinAnnotationView*)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"MyAnnotation"];
if (!pinView) {
pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotation"];
}
else
pinView.annotation = annotation;
//If I set this to true, my image is replaced by the pin
//pinView.animatesDrop = true;
//I'm using SDWebImage
[pinView setImageWithURL:[NSURL URLWithString:@"/pathtosomeavatar.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
//Adding a nice drop shadow here
pinView.layer.shadowColor = [UIColor blackColor].CGColor;
pinView.layer.shadowOffset = CGSizeMake(0, 1);
pinView.layer.shadowOpacity = 0.5;
pinView.layer.shadowRadius = 3.0;
return pinView; …
Run Code Online (Sandbox Code Playgroud) 我正在使用SQL服务器和几个数据库.每个数据库可能有很多架构,比如dbo.,admin.,other.而且我已经厌倦了滚动试图找到的东西.
如果我正在处理特定于模式的项目,我想从我的视图中过滤掉除模式之外的所有其他内容.作为dbo,我看到一切意味着我花了大部分时间来骚扰我的滚轮(这是一个笑话).
这可能在SQL Server Management Studio 2008中吗?
我有一个带有QueriesTableAdapter的DataSet.为了控制SqlCommand.CommandTimeout,我添加了一个名为QueriesTableAdapter的分部类,其中包含一个名为ChangeTimeout的公共方法.
partial class QueriesTableAdapter
{
public void ChangeTimeout(int timeout)
{
foreach (System.Data.SqlClient.SqlCommand cmd in CommandCollection)
{
cmd.CommandTimeout = timeout;
}
}
}
Run Code Online (Sandbox Code Playgroud)
对于每个拥有QueriesTableAdapter的DataSet,我可以在执行之前设置CommandTimeout.
using (NameSpace.DataSet.DataSetTableAdapters.QueriesTableAdapter ta =
new NameSpace.DataSet.DataSetTableAdapters.QueriesTableAdapter())
{
ta.ChangeTimeout(3600);
ta.DoSomething();
}
Run Code Online (Sandbox Code Playgroud)
这在大多数情况下都很有效,因为"QueriesTableAdapter"是在DataSet设计器中为您命名的.我遇到的问题是具有唯一名称的TableAdapter.例如,如果我有一个名为Person的DataTable和一个名为PersonTableAdapter的TableAdaper,我必须像编写QueriesTableAdaper类一样编写PersonTableAdapter分部类.我有数百个具有唯一TableAdapter名称的DataTable.我不想为每个人创建一个部分类.如何以全局方式访问部分类的基础SqlCommand对象?
我正在尝试整理一个可编辑的详细视图,类似于iPhone默认联系人应用程序.
我有一个联系人的TableView,当我选择一个单元格时,我会激活一个可编辑的详细信息视图:
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
var editingSection = new Section ("Entity") {
new StringElement ("First name", "enter", _entity.FirstName),
new StringElement ("Last name", "enter", _entity.LastName)
};
var root = new RootElement("Entity Entry") {
editingSection
};
var entityEdit = new EntityEdit (root, true);
ConfigEdit (entityEdit);
dvc.ActivateController(entityEdit);
}
void ConfigEdit (DialogViewController dvc)
{
dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Edit, delegate {
dvc.TableView.SetEditing (true, true);
ConfigDone (dvc);
});
}
void ConfigDone (DialogViewController dvc)
{
dvc.NavigationItem.RightBarButtonItem = new …
Run Code Online (Sandbox Code Playgroud) 我一直在将我们的解决方案从VS 2005升级到VS 2008; 仍然以.net 2.0框架为目标.转换向导很简单,我从来没有转换失败.到目前为止我唯一的优点是我无法在升级后立即编译,因为VS已经改变了我的一些命名空间导致命名冲突.
例如,我有一个DAL项目(我们称之为MyNameSpace),它有一个"Clients"文件夹,其中包含一个名为"dsClient"的数据集.
以下是转换前数据集设计器类的外观:
namespace MyNameSpace
{
public partial class dsClient : global::System.Data.DataSet
{
}
}
Run Code Online (Sandbox Code Playgroud)
在转换过程中,VS正在更改我的设计器类并将文件夹名称添加到命名空间的末尾,所以现在它看起来像这样:
namespace MyNameSpace.Clients
{
public partial class dsClient : global::System.Data.DataSet
{
}
}
Run Code Online (Sandbox Code Playgroud)
这个问题是我在该文件夹中有另一个具有相同名称的类文件:
namespace MyNameSpace
{
public class Clients
{
}
}
Run Code Online (Sandbox Code Playgroud)
这会导致命名冲突,我必须手动修复VS所做的更改.在某些情况下,VS会将命名空间名称更改为数据集的名称,而不是文件夹的名称.
这是转换向导中的配置吗?我想让向导只更新项目文件并保留代码.
我有一个表格。该表单有一个用户控件。该用户控件有一个面板和一个上下文菜单。上下文菜单未附加到面板。还有其他动态创建并添加到此面板的控件。这些控件之一是按钮。当您单击此按钮时,我将 contextmenustrip 属性设置为上下文菜单。
我的问题是,我需要先阅读该上下文菜单中的项目,然后才能将上下文菜单附加到按钮。
每次加载表单时,我都会迭代该表单的所有子控件。如果一个控件有子控件,我会迭代这些控件,依此类推...我似乎无法访问未分配的上下文菜单。它尚未附加到任何控件,因此它看起来不是窗体上任何控件的子控件。
myConectMenu 永远不会像 this.Controls.Add(myConectMenu) 这样添加到用户控件中。该上下文菜单如何不嵌套在表单控件集合中?我怎样才能进入该上下文菜单?
这是设计师代码:
private System.Windows.Forms.ContextMenuStrip myContextMenu;
void InitializeComponent()
{
this.myContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.myContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.myToolStripMenuItem1,
this.myToolStripMenuItem2});
this.myContextMenu.Name = "myContextMenu";
this.myContextMenu.Size = new System.Drawing.Size(158, 92);
}
Run Code Online (Sandbox Code Playgroud)
更新 控件迭代发生在一个基类中,我的应用程序中的所有表单都从该基类派生。
myContextMenu 添加到一个私有组件对象中。我想这是因为当它没有附加到控件时,您可以在设计视图中看到上下文菜单。也许我可以利用这个?
private System.ComponentModel.IContainer components = null;
this.myContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
Run Code Online (Sandbox Code Playgroud) 它可以访问节头和页脚的字体和颜色属性,还是我需要继承Section?我将我的UI改为全黑,除了我的章节页眉和页脚之外,一切看起来都很棒.
反思API:
class Login
{
public string Version = "1.2.3";
[Section ("Enter your credentials", "Email and password are required")]
[Entry ("Enter your email address")]
public string email;
[Caption ("Password"), Password ("Enter your password")]
public string password;
[OnTap ("Login")]
[Alignment (UITextAlignment.Center)]
public string Logon;
}
Run Code Online (Sandbox Code Playgroud)
元素API:
return new RootElement ("Login") {
new Section() {
new StringElement ("Version", "1.2.3")
},
new Section ("Enter your credentials", "Email and password are required") {
new EntryElement("Email", "Enter your email address", "azcoov"),
new EntryElement("Password", "Enter your …
Run Code Online (Sandbox Code Playgroud) 我将XML字符串发布到AIX机器上的端口.我有两种方法可以连接到这个盒子(TcpClient和HttpWebRequest).我有计时器让我知道AIX盒子处理我的请求和响应需要多长时间.
看起来TcpClient比HttpWebRequest快了100毫秒.我怀疑我的计时器位置可能不正确.无论哪种方式,我都不认为计时器位置会在响应时间上产生如此大的差异.
我的另一个想法是使用声明.也许他们保持连接打开时间比TcpClient更长.
已知TcpClient方法更快吗?
// TcpClient
TcpClient client = new TcpClient(host, port);
DateTime x = DateTime.Now;
NetworkStream stream = client.GetStream();
NetworkStream stream = client.GetStream();
stream.Write(request, 0, request.Length);
stream.Flush();
while ((count = stream.Read(buffer, 0, buffer.Length)) > 0)
response.Append(encoder.GetString(buffer, 0, count));
DateTime y = DateTime.Now;
totalMS = y.Subtract(x).TotalMilliseconds;
// HttpWebRequest
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(URI);
using (Stream webStream = webRequest.GetRequestStream())
{
webStream.Write(postdata, 0, postdata.Length);
webStream.Close();
DateTime x = DateTime.Now;
using (WebResponse webresponse = webRequest.GetResponse())
{
webresponse.Close();
DateTime y = DateTime.Now;
using (Stream rs …
Run Code Online (Sandbox Code Playgroud) 我有一个类似这样的英语短语:“我有 {0} 只狗和 {1} 只猫”。在代码中,我使用 String.Format 提供数据:
String.Format("I have {0} dogs and {1} cats", 1, 2)
Run Code Online (Sandbox Code Playgroud)
所以输出是这样的:“我有 1 只狗和 2 只猫”。
我要解决的问题是“我有 {0} 只狗和 {1} 只猫”这句话需要翻译成其他语言。
在此西班牙语翻译示例中,英语短语“我有 {0} 条狗和 {1} 条猫”和翻译后的短语“Tengo {0} perros y gatos {1}”存储在数据库中。
如果用户将“Tengo {0} perros y gatos {1}”更改为“Tengo {0} perros y gatos {3}”,当我调用 String.Format("Tengo {0} } perros y gatos {3}", 1, 2).
现在我正在捕获格式异常,感觉不对。我正在寻找更好的解决方案的想法。
c# ×5
xamarin.ios ×2
angularjs ×1
asp.net ×1
ios ×1
localization ×1
mkmapview ×1
objective-c ×1
sql-server ×1
ssms ×1
string ×1
tableadapter ×1
tcp ×1
translation ×1
winforms ×1