首先,这是我的错误的错误日志条目
crash program @ 15-9-2011 15:01:30error:System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
无论如何代码:
private void TB_postcode_cijfers_TextChanged(object sender, TextChangedEventArgs e){
if (TB_postcode_cijfers.Text != string.Empty || TB_postcode_cijfers.Text.Length > 0)
{
LBL_postcode.Content = Postcode_cijfers + Postcode_letters;
if (TB_postcode_cijfers.Text.Length == 4 && TB_postcode_letters.Text.Length == 2)
{
if (!ZoekOpPostcode(Injectioncheck(TB_postcode_cijfers.Text + TB_postcode_letters.Text)))
{
//MessageBox.Show("Geen resultaat gevonden, " + errortext);
if (MessageBox.Show("Geen resultaat gevonden, " + errortext + ".\n Wilt u …Run Code Online (Sandbox Code Playgroud) 为了澄清我有一个组合框,其可观察的集合绑定到其itemsource属性.我希望用户只能输入集合中存在的项目.同时保持
IsTextSearchEnabled="true"
Run Code Online (Sandbox Code Playgroud)
功能.所以我一直在网上寻找一个如何做到这一点的例子.直到现在我想我应该使用
<ComboBox TextInput="cbb1_TextInput" />
Run Code Online (Sandbox Code Playgroud)
事件然后搜索集合.但我虚弱的尝试不能维持自动完成功能,selectedindex混乱和其他不需要的行为.因为我是wpf中的一个菜鸟,我想知道是否有只使用XAML部分的解决方案?
编辑: 我尝试过这样的事情:
private void fase1cbb1_KeyUp(object sender, KeyEventArgs e)
{
ComboBox cb = (ComboBox)sender;
bool match = false;
TextBox tb = (TextBox)cb.Template.FindName("PART_EditableTextBox", cb);
if (tb.Text.Length > 0)
{
foreach (MenuItem MI in cb.Items)
{
if (MI.Text.StartsWith(tb.Text))
{
match = true; ;
}
}
if (!match)
{
int len = tb.Text.Length;
if (len > 0)
{
tb.Text = tb.Text.Substring(0, len - 1);
tb.SelectionStart = len;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是一旦没有匹配,就没有更多的选定项目,也没有更多的自动完成/文本搜索.
thnx任何建议或例子.
我在过去一周左右搜索并尝试了不同的东西,我的问题可能是通过谷歌找到答案.
如果我执行在SQL Server Management Studio中此查询和替换的参数@zoekterm有'%something%',它工作正常,并返回我想要的结果.但是当我从C#调用相同的程序时,它什么也没有返回.
这是一个错误还是我那么愚蠢?
这是C#中存储过程和函数的代码,(我知道我应该使用switch case ...)
存储过程:
-- =============================================
-- Author: Daan
-- Create date:
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[quick_bedrijf]
-- Add the parameters for the stored procedure here
@zoekterm varchar(100) = 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT bedrijf.bedrijf_nr, bedrijf.zoeknaam, bedrijf.plaats
FROM bedrijf
WHERE zoeknaam LIKE @zoekterm AND …Run Code Online (Sandbox Code Playgroud) 快(我希望)问题.我有这个DataGrid,包含一些货币列.我似乎无法找到的是如何以2位小数显示货币.但是在单元格中保持可能的3或4十进制值.如果尝试了一些字符串格式,但实际上会更改值.当然,IValueConverter也是如此.那我错过了什么?或者有人能指出我正确的方向吗?
编辑:在建议后我尝试了这样的事情.
<Style x:Key="DecimalTextBlockStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="TextBlock.Text" Value="{Binding StringFormat={}{0:C}}"/>
<Setter Property="TextBlock.Foreground" Value="Red"/>
<Setter Property="Background" Value="AliceBlue"/>
</Style>
Run Code Online (Sandbox Code Playgroud)
并在这里申请:
if(e.PropertyType.FullName.Contains("Decimal"))
{
var cl = e.Column as DataGridTextColumn;
if (cl != null)
{
//cl.Binding.StringFormat = "C2";
Style Stl = (Style)FindResource("DecimalTextBlockStyle");
cl.CellStyle = Stl;
}}
Run Code Online (Sandbox Code Playgroud)
但我没有得到的是为什么!这些列中的值是漂亮的红色文本,蓝色背景..但是未格式化的字符串,只显示0,000而不是€0,00
搜索谷歌和stackoverflow之后我无法找到一个帮助我在我的情况下的答案.我有一个带有开始菜单(表单)的应用程序.当用户按下(任意)表格的X(关闭)时,我重新加载开始菜单.现在,当(菜单)表单关闭时,我想检查并通知用户现在任何隐藏的表单处于编辑模式(有或没有未保存的更改),如果用户按下取消我想显示该表单并停止应用程序关闭.现在我的问题是如何阻止应用程序停止在其他表单的代码中.我有一个覆盖调用this.close的子窗体的dispose方法,所以ok/cancel消息框显示但是在MB之后,开始菜单关闭,无论如何停止程序.我应该寻找一种处理这些东西的不同方法,还是要修改方法或事件处理程序,以便这个/ \可以工作?
编辑:确定这里的代码部分是被调用的顺序.我哪里出错了?
private void Menu_FormClosing(object sender, FormClosingEventArgs e)
{
Global.Forms.Remove(this);
if (!Global.Clean_Forms())
{
e.Cancel = true;
Global.Forms.Add(this);
}
}
public static void Clean_Forms()
{
foreach (Form f in Forms)
{
if (f is Menu)
{
//do nothing
}
else
{
if (!f.IsDisposed)
{
f.Close();
}
}
}
if (Forms.Count != 0)
{
isClean = false;
/* String a = "";
foreach (Form f in Forms)
{
a += f.ToString() + ": ";
}
MessageBox.Show(a);*/
}
else
{
isClean = …Run Code Online (Sandbox Code Playgroud)