如何在只读数据网格中使一列可编辑?
<DataGrid x:Name="dgLoadDtl" Height="315" Width="710" Grid.Row="0"
HorizontalAlignment="Left" VerticalAlignment="Bottom"
Style="{DynamicResource StyleDatagrid}"
IsReadOnly="true">
<DataGrid.Columns>
<DataGridTextColumn Foreground="Black" Width="60" Header="Sctn" Binding="{Binding Sctn, Mode=TwoWay}" IsReadOnly="false" />
<DataGridTextColumn Foreground="Black" Width="140" Header="CustName" Binding="{Binding CustName, Mode=TwoWay}" />
<DataGridTextColumn Foreground="Black" Width="140" Header="Address" Binding="{Binding Address1, Mode=TwoWay}" />
<DataGridTextColumn Foreground="Black" Width="50" Header="Bulk or Bag" Binding="{Binding BulkorBag, Mode=TwoWay}" />
<DataGridTextColumn Foreground="Black" Width="80" Header="ProdCode" Binding="{Binding ProdCode, Mode=TwoWay}" />
<DataGridTextColumn Foreground="Black" Width="80" Header="MedCode" Binding="{Binding MedCode, Mode=TwoWay}" />
Run Code Online (Sandbox Code Playgroud)
我有一个数据网格绑定到数据库表.我需要将行的前景颜色更改为蓝色,具体取决于其中一列中的值.有没有办法可以做到这一点?我尝试过IValueConverter,但我认为我一次只能将它用于一个单元格.
我知道之前有人问这个问题,但我无法找到我要找的东西.
private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (oOrdItem.ItemNo == 0)
{
e.Handled = true;
MessageBox.Show("Please save the order item", "Save");
return;
}
}
Run Code Online (Sandbox Code Playgroud)
即使我调用e.Handled = true;
它也会选择datagrid行.我不想打电话,dataGrid1.SelectedIndex =-1;
因为它会再次触发selectionchanged事件.我还尝试过dataGrid1.UnSelectAll();
任何其他方式来取消selectionchanged事件?
我有一个Kendo ui图表,它显示了动态数据源的柱形图.但偶尔,图表的可用空间大小只有一半.当我点击某些链接或更改日期时,它会自行调整大小.知道为什么会造成它吗?
在datasource change事件中,当它显示此行为时,它将容器div的宽度显示为0.如果需要,我可以提供更多细节
我尝试了其中一个答案中给出的刷新方法,但它没有帮助
需求:
每天在特定时间(例如早上6点)动态地向所有用户发送电子邮件.
到目前为止我做了什么:
我使用Nuget的第三方库Quartz.net.
public class TaskScheduler : IJob
{
public void Execute(IJobExecutionContext context)
{
try {
UserRepository userRepo = new UserRepository();
var users = userRepo.GetUsers();
DashBoardRepository repo = new DashBoardRepository();
foreach (var rec in users)
{
var tasks = repo.GetIncompleteTasks(rec.UserID);
var appointments = repo.GetUpcomingAppointments(rec.UserID);
if (tasks.Count > 0 || appointments.Count > 0)
{
dynamic email = new Email("TaskEmail");
email.To = rec.Email;
email.From = "no-reply@xyz.com";
email.Subject = "Pending items in XYZ";
email.Tasks = tasks;
email.Appointments = appointments;
email.Send();
}
} …
Run Code Online (Sandbox Code Playgroud) 我有两个资源词典.一个叫做ResDictGlass.xaml,另一个叫做ResDictNormal.xaml.两者都具有相同的属性和不同的值.例如
ResDictGlass.xaml有一个这样的样式:
<Style x:Key="StyleTitleText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="Green" />
</Style>
Run Code Online (Sandbox Code Playgroud)
ResDictNormal.xaml中的相同样式是:
<Style x:Key="StyleTitleText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Tahoma" />
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="WhiteSmoke" />
</Style>
Run Code Online (Sandbox Code Playgroud)
我在xaml中设置了textblock:
<TextBlock Style="{DynamicResource StyleTextblock}" Text="Prod.Code" VerticalAlignment="Top" />
Run Code Online (Sandbox Code Playgroud)
我想在运行时切换这些样式.我做的是这样的:
case "normal":
ResourceDictionary ResDict1 = new ResourceDictionary();
ResDict1.Source = new Uri("/ResDictNormal.xaml", UriKind.RelativeOrAbsolute);
Application.Current.Resources.MergedDictionaries.Add(ResDict1);
break;
case "flip":
ResourceDictionary ResDict2 = new ResourceDictionary();
ResDict2.Source = new Uri("/ResDictGlass.xaml", UriKind.RelativeOrAbsolute);
Application.Current.Resources.MergedDictionaries.Add(ResDict2);
break;
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?我们是否必须删除当前字典然后添加字典?
我正在尝试使用Kendo移动小部件 - 在我的Web应用程序中切换如下:
<input id="btnConvert" type="checkbox" onclick="onChange();" />
$(document).ready()
{
$("#btnConvert").kendoMobileSwitch({
onLabel: "UK",
offLabel: "US"
});
}
function onChange(e) {
alert(e.checked);//true of false
}
Run Code Online (Sandbox Code Playgroud)
但它没有触发点击事件.我尝试了onchange事件,这也是行不通的.
我也试过了
$('input:checkbox').change(function () {
}
Run Code Online (Sandbox Code Playgroud)
但没有成功......
我有一个linq查询,它从customer表中获取所有记录到一个可观察的集合,如下所示:
customerList = new ObservableCollection<customer>(dbContext.customers);
dgRecords1.ItemsSource = customerList;
Run Code Online (Sandbox Code Playgroud)
该列表绑定到数据网格.customer表包含近百个字段.但是我只在数据网格上显示了几个字段.我的问题是
是否只使用linq查询从数据库中引入选定的字段可以提高客户屏幕的速度?
我需要过滤并有时删除此列表中的记录.
哪个是选择几个字段到可观察集合的最佳方法,有人可以提供一些示例linq查询吗?
在我的剑道网格中,我有一种情况,当他们点击一个单元格时,它将处于编辑模式.但根据条件,我需要取消编辑.
我尝试使用代码来模拟jQuery中的转义键,但是没有用.
我有一个WPF应用程序,窗口变小,如果它被取消激活,移动到侧面.但是如果窗口上打开了消息框,我不希望发生此功能.有没有办法可以检查C#代码中是否有任何对话框打开?
wpf ×6
datagrid ×3
kendo-ui ×3
c# ×2
asp.net-mvc ×1
jquery ×1
kendo-mobile ×1
linq ×1
postal ×1
quartz.net ×1
xaml ×1