$_GET['name']如果值没有在url中传递,那么会变化什么?我用Google搜索,但无法想出任何东西.
有没有办法格式化绑定到数据网格的值?例如,我有以下内容:
<DataGrid AutoGenerateColumns="False" Height="487" HorizontalAlignment="Left" Margin="12,12,0,0" Name="dgTransactionLog" VerticalAlignment="Top" Width="404">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Date}" Header="Date" />
<DataGridTextColumn Binding="{Binding Path=Payee1.Name}" Header="To/From" />
<DataGridTextColumn Binding="{Binding Path=Amount}" Header="Amount" />
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
我希望Date列只是日期(而不是时间),Amount列是货币格式.以下是我填充数据网格的方法:
var transactions = TransactionManager.GetTransactions();
dgTransactionLog.ItemsSource = transactions;
Run Code Online (Sandbox Code Playgroud) 我想在一个位打包的结构中有一个数组.我静态地知道数组的大小(32),我希望数组中的每个元素都是一个位.例如,我希望能够说出类似的话:
struct example_s {
// ...
unsigned int flags[32] : 32;
} __attribute__((__packed__));
Run Code Online (Sandbox Code Playgroud)
我尝试了几件事,但是gcc不会让步.能够这样做是很好的,这样我就可以编写遍历打包数组中元素的干净代码.想法?
作为一个学习者,我喜欢看很多源代码.自从我在一年前开始学习JavaScript以来,我注意到人们不使用传统事件处理程序的趋势onclick="doSomething()",但是越来越多地使用像document.getElementById("someId").onclick = function(){..some code..};
这种趋势背后的原因是什么?
我开始学习OpenGL与iOS一起使用它.我想知道为什么类似glMatrixMode或常量的方法GL_PROJECTION存在<OpenGLES/ES1/gl.h>,但不是<OpenGLES/ES2/gl.h>.为什么?在使用OpenGL ES 2.0而不是1.1时,您是否强制编写自己的着色器?
我正在尝试从硬盘驱动器中的HTML文件中提取电子邮件信息.
如果我在firefox中加载文件并运行jQuerify bookmarklet,我可以成功使用以下选择器/函数
window.jQuery("a.iEmail").each(function(el) {
console.log(window.jQuery(this).attr('href'))
});
Run Code Online (Sandbox Code Playgroud)
但是在Node.js中使用它是行不通的
var document = require("jsdom").jsdom(),
script = document.createElement("script"),
fs = require('fs');
fs.readFile('file_1.html', 'utf-8', function(err, data){
if (err) {
throw err;
}
// This output the document
//console.log(data)
var window = document.createWindow(data);
script.src = 'http://code.jquery.com/jquery-1.4.2.js';
script.onload = function() {
console.log(window.jQuery.fn.jquery);
// outputs: 1.4.2
//console.log(window.jQuery);
/*
* This line works if i load the local file in firefox and execute
* the jQuerify bookmarlet
*/
window.jQuery("a.iEmail").each(function(el) {
console.log(window.jQuery(this).attr('href'))
});
};
document.head.appendChild(script);
});
Run Code Online (Sandbox Code Playgroud) 可能重复:
C++单例与完全静态对象
嗨,
为什么我更喜欢单例而不是静态类方法.
MoneyPrinter::addJob(PrinterJob &job);
or
MoneyPrinter::getInstance().addJob(PrinterJob &job);
Run Code Online (Sandbox Code Playgroud)
这只是风格问题吗?你用什么?为什么?
PS.我知道sigletons默认情况下不是线程安全的(第一次初始化).
考虑以下带有文本框和webbrowser控件的简单WinForms表单.每当文本框内容发生变化时,文本都会被推送到浏览器:
public class MainForm : Form
{
public MainForm()
{
var browser = new WebBrowser() { Dock = DockStyle.Fill };
var textbox = new TextBox() { Dock = DockStyle.Fill, Multiline = true };
var splitter = new SplitContainer() { Dock = DockStyle.Fill };
splitter.Panel1.Controls.Add(textbox);
splitter.Panel2.Controls.Add(browser);
this.Controls.Add(splitter);
textbox.TextChanged += delegate { browser.DocumentText = textbox.Text; };
textbox.Text = "<b>hello world</b>";
}
}
Run Code Online (Sandbox Code Playgroud)
(我在DownMarker代码中做了类似的事情,用Stackoverflow的MarkdownSharp库构建Markdown编辑器.)
这很好用,除了WebBrowser控件坚持在DocumentText设置时显示等待光标- 即使更新浏览器内容只需要几毫秒.在文本框中键入时,这会导致鼠标光标闪烁.
有没有办法来抑制这些鼠标光标的变化?我已经考虑过限速DocumentText更新,但我发现更新期间偶尔的闪烁仍然很烦人,我更喜欢即时更新.
textbox.TextChanged +=
delegate
{ …Run Code Online (Sandbox Code Playgroud) 我正在努力保存更大的对象结构,其中包含我正在处理的应用程序中"项目"所需的所有数据.数据是诸如图片,流文档以及更基本的数据类型之类的东西.
现在,我目前的方法是在我需要保存的对象中包含的所有类上实现ISerializable.但是,当:
public class Profile : ISerializable
{
public ObservableCollection<Trade> Trades { get; set; }
public Profile() {}
public Profile(SerializationInfo info, StreamingContext context)
: this()
{
foreach (SerializationEntry entry in info)
{
if (entry.Name.StartsWith("trade"))
{
Type t = entry.ObjectType;
Trades.Add(entry.Value as Trade);
}
}
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
int i = 0;
foreach (Trade t in Trades)
{
info.AddValue("trade" + i, t, t.GetType());
i++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
它造成了一个问题.填充我的List的Trade-class也实现了ISerializable.所以我很想知道:这是一个好方法吗?它甚至有用吗?我到目前为止编写的代码不起作用,我仍在尝试解决这些问题.
更具体地说,将是info.AddValue("trade"+ i,t,t.GetType()); 使用贸易级的ISerializable方法?或许这个界面甚至不打算处理这些类型的类.
因此,如果有人会如此善良,并采取一些看法,并指出我在这些事情的序列化方面的正确方向.
谢谢!
我的应用程序通过URL中的公司标识符分隔用户:company1.app.com,company2.app.com ...
我正在我的本地PC上测试请求,例如:company1.localhost.com.但是,我的request.Url.Authority仍显示"localhost.com"而不是"company1.localhost.com".实际上,'company1'的前缀并未显示在任何地方.这是一个错误还是一个功能?
值得注意的是,我在主机文件中添加了"comapany.Blah - > 127.0.0.1"的条目.在查看Request.Url.Authority时,STIL显示localhost ...