我试图在VS2010中创建的实体模型上使用SQL查询填充DataGrid.
public List<MovieTable> LoadMoviesMethod()
{
ObjectQuery<MovieTable> _movies = dataEntities.MovieTables;
var query =
from MovieTable in _movies
//where MovieTable.Rating == "R"
//orderby MovieTable.id
select MovieTable;
return query.ToList();
}
Run Code Online (Sandbox Code Playgroud)
导入数据库时会自动生成对象MovieTable,但是当它显示在网格上时,它会显示比我想要的更多的信息(id,EntityKey和EntityState).试图在对象中选择某些属性我得到了字符串,并返回return语句.有没有办法选择MovieTable的某些成员在数据网格上显示?也许指定我想要显示的列?看起来很简单,但我想我还不够好想出来!!!!
我试图在双击事件后从数据网格中检索行信息.我有事件设置,但现在我只需要设置函数来从行中检索数据.
XAML:
<DataGrid
Width="Auto"
SelectionMode="Extended"
IsReadOnly="True"
Name="ListDataGrid"
AutoGenerateColumns="False"
ItemsSource="{Binding ListFieldObject.MoviesList}"
DataContext="{StaticResource MovieAppViewModel}"
cal:Message.Attach="[Event MouseDoubleClick] = [Action RowSelect()]">
<DataGrid.Columns>
<DataGridTextColumn Width="200" IsReadOnly="True" Header="Title" Binding="{Binding Title}"/>
<DataGridTextColumn Width="100" IsReadOnly="True" Header="Rating" Binding="{Binding Rating}"/>
<DataGridTextColumn Width="100" IsReadOnly="True" Header="Stars" Binding="{Binding Stars}"/>
<DataGridTextColumn Width="93" IsReadOnly="True" Header="Release Year" Binding="{Binding ReleaseYear}"/>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
C#(MVVM ViewModel):
public void RowSelect()
{
//now how to access the selected row after the double click event?
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!
我只是无法将我的变量转移到下一页.变量赋值在初始页面(测试)上工作正常,但是当转到下一个时,该值变为null.Plz帮助!
第1页:
<?PHP session_start(); ?>
<HTML>
<HEAD>
<META NAME='robots' CONTENT='noindex,nofollow'>
<TITLE>Master Chief's Gamestore</TITLE>
<STYLE type="text/css">
BODY {
color: #ffffff;
background: url('~/halo-reach.jpg');
background-repeat: no-repeat;
background-position: top;
background-color: black;
}
</STYLE>
</HEAD>
<body vLink='#3366CC' link='#3366CC' alink='#3366CC'>
<br/><br/><br/><br/><br/>
<table width='100%' height='80%'>
<tr>
<td align='center' valign='middle'>
<table width="50%" cellspacing="0" cellpadding="25" border="0">
<form method="post">
<tr bgcolor="#666633">
<th id="header" align="left" colspan="3">
<DIV align="center">
<font face="Verdana, Arial, Helvetica" color="white" size="3">
Master Chief's Gamestore </font>
</DIV>
</th>
</tr>
<tr bgcolor="#A3A385">
<td width="100%" valign="middle" colspan="2">
<font face="Verdana, Arial, …Run Code Online (Sandbox Code Playgroud) 我在这个问题上发现了很多文章,但似乎都没有.我有3个DataTemplateColumns,两个带有文本框,另一个带有切换按钮.通过首先切换到单元格,然后是内容.我从其他网站和我自己的发明中尝试过很多建议而没有任何运气.我可以让它在第一行工作,当我添加另一行时,但一次添加2并且它停止工作.我恨.DataTemplate中.列.这是当前使用依赖属性的类im.
public class FocusAttacher
{
public static readonly DependencyProperty FocusProperty =
DependencyProperty.RegisterAttached("Focus",
typeof(bool),
typeof(FocusAttacher),
new PropertyMetadata(false, FocusChanged));
public static bool GetFocus(DependencyObject d)
{
return (bool)d.GetValue(FocusProperty);
}
public static void SetFocus(DependencyObject d, bool value)
{
d.SetValue(FocusProperty, value);
}
public static void FocusChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue)
{
((UIElement)sender).Focus();
}
}
Run Code Online (Sandbox Code Playgroud)
<DataGridTemplateColumn Header="Some Value"
MinWidth="30"
Width=".02*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding SomeBinding,
ValidatesOnDataErrors=True,
UpdateSourceTrigger=PropertyChanged}"
IsReadOnly="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type DataGrid}},
Path=DataContext.IsReadOnly}"
Style="{StaticResource SomeStyle}"
customControls:FocusAttacher.Focus="True"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
奇怪的是,这仅适用于文本框,而不适用于我的第三列中的切换按钮.哎呀!!!!!
编辑:这是Button的DataTemplate.它被设置为严格用于样式和触发目的的自定义控件.它是一个带有controltemplate的Button,包含一个border和contentpresenter.
<DataTemplate>
<customControls:MetroButton …Run Code Online (Sandbox Code Playgroud) 我正在尝试刷新页面以更新文本框中的值,但我得到了一个无限循环.
"Firefox检测到服务器正在以永远不会完成的方式重定向该地址的请求."
if($POST_['rem1'] != $quantity){
$query = "update cart set quantity=".$_POST['rem1'].";";
mysql_query($query);
header('Location: http://~/cart.php');
Run Code Online (Sandbox Code Playgroud)
}
有没有人对如何执行一次或更好的实现有任何建议?
谢谢!
我试图在鼠标悬停时更改图像的位置。我有:
<Image
Name="cat"
Source="CatRun.bmp"
Visibility="Hidden"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="100"
Height="100"
UIElement.MouseEnter="cat_MouseEnter"/>
Run Code Online (Sandbox Code Playgroud)
在 XAML 中以及:
private void cat_MouseEnter(object sender, MouseEventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)
在 C# 中。
如何在画布上专门设置位置?
由于某种原因,此代码立即执行父命令,终止我的信号量并搞砸了我对其他程序的流控制.谁能告诉我为什么waitpid()不起作用?
//Create child processes
pid = fork();
if(pid < 0){
fprintf(stderr, "Fork Failed.\n");
exit(1);
return;
}else if(pid==0){
if(execl("/home/tropix/hw11-2","/home/tropix/hw11-2",semarg,pipe_to_p3,pipe_to_p4,(char*)0)){
fprintf(stderr, "File Exexecution of hw11-2 failed.\n");
exit(1);
}
} else {
pid = fork();
if(pid < 0){
fprintf(stderr, "Fork Failed.\n");
exit(1);
return;
} else if(pid==0){
if(execl("/home/tropix/hw11-3","/home/tropix/hw11-3",shmarg,semarg,pipe_from_p2,pipe_to_p5_1, (char*)0)){
fprintf(stderr, "File Execution of hw11-3 failed.\n");
exit(1);
}
} else {
pid = fork();
if(pid < 0){
fprintf(stderr, "Fork Failed.\n");
exit(1);
return;
} else if (pid == 0){
if(execl("/home/tropix/hw11-4","/home/tropix/hw11-4",shmarg,semarg,pipe_from_p2_2,pipe_to_p5_2, (char*)0)){
fprintf(stderr, "File Execution of hw11-4 …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过数据网格进行选项卡,但在行的末尾我有一个包含选项卡的模板列。我已将数据网格单元格样式设置为不可聚焦并且 istabstop = false,但它似乎仍然进入内容。TemplateColumn 是否有一个属性可以通过 Tab 键完全跳过它?
谢谢