|
Basically, you probably have two datagrids bound to datasources, right? All you do is copy the data from one datasource to the other. That's all. I can't give you the implementation details because you haven't provided any detail about your datasources.
I can tell you you're probably going to have an issue with having these datagrids on two different forms. Unless your datasources are exposed globally (not a great idea) or both forms can get to the sources themselves, you've made this process more complicated than it needs to be.
|
|
|
|
|
Hello
Have search far and wide for something that I think should be on MSDN, but no luck. It must be something simple, but I'm not that good with FP.
Anyway, I have List(Of MyObject) that I want to filter for an auto complete box.
Currently, I do this:
NameACB.ItemFilter = New AutoCompleteFilterPredicate(Of Object)(AddressOf NameSearch)
And then have this function for it to land on:
Private Function NameSearch(ByVal search As String, ByVal value As Object) As Boolean
Dim cust As MyCustomer = TryCast(value, MyCustomer)
If cust Is Nothing Then Return False
If cust.Name.ToLower.Contains(search.ToLower) Then
Return True
Else
Return False
End If
End Function
This works fine, but to cut down on the code (and maybe learn somthing), I was trying to use a lambda expression instead. This is what I thing it should look like:
NameACB.ItemFilter = New AutoCompleteFilterPredicate(Of MyCustomer)(Function(f As MyCustomer) If(f.Name= NameACB.Text, True, False))
But this throws a compiler error that the nested function doesn't have the same signature as delegate.
modified on Friday, September 25, 2009 2:27 AM
|
|
|
|
|
Since I'm not really sure what the definition of either AutoCompleteFilterPredicate or NameACB is, I can only point out that you did this the first time:
NameACB.ItemFilter = New AutoCompleteFilterPredicate(Of Object)(...)
and this the second time:
NameACB.ItemFilter = New AutoCompleteFilterPredicate(Of MyCustomer)(...)
The problem may not be with your lambda, but may be with trying to assign a delegate with that signature to a property that expects another signature.
P.S. There's no reason to write If(f.Name = NameACB.Text, True, False) (or it's multi-line equivalent). You can just say Return (f.Name = NameACB.Text) and get the exact same thing with less code the better expresses your intent.
|
|
|
|
|
Thank you for you reply Gideon!
Reading my original message, I realise I've been a bit short.
NameACB is an AutoCompleteBox(ACB), and I have attached a List(Of MyCustomer) to
its ItemsList. Now, MyCustomer has many fields, and when in doubt, ACB
defaults to searching by the .ToString value of an object. Because of some quirks
of WCF, I can't override the .ToString method in my objects, and so I have
to define the .ItemFilter property of the ACB, by way of the AutoCompleteFilterPredicate.
As far as I can tell It just loops trough all the instances in ItemList and returns
True if they match in the prescribed field, and False otherwise, using either a seperate
function or a lambda expression.
Anyway, your suggestion is one of many I tried, without sucess. I suppose it's not so
much a FP question as an UI problem, but if I understand you, you think it should be more like:
NameACB.ItemFilter = New AutoCompleteFilterPredicate(Of Object)(Function(f As MyCustomer) f.Name=NameACB.Text))
|
|
|
|
|
It appears you are using the AutoCompleteBox from the Silverlight library (finally found it). If so, you will need to change the lambda signature to Function(String, Object) As Boolean to match the signature expected by ItemFilter. This means that you will have to cast the item argument inside the lambda, like so:
NameACB.ItemFilter = _
New AutoCompleteFilterPredicate(Of Object)( _
Function(search, f) CType(f, MyCustomer).Name=NameACB.Text) _
)
You cannot pass a lambda of (string, MyCustomer)->Boolean to a function of (string, object)->Boolean because then you could not pass arguments of (string, int).
|
|
|
|
|
Thank you!
This works. And all I had to do was roll the function into one line of code!
I guess I over-thought the whole thing in the beginning. Thanks again.
|
|
|
|
|
Hello
i got all the keys to work in my screen keyboard but i cant get the under score working
i went online and found the hex code for it H5F
Anyone Have any ideas ??
Private Sub Key_US_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Key_US.Click
SetActiveWindow(8975651603260375040)
keybd_event(&H5F, 0, 0, 0)
keybd_event(&H5F, 0, KEYEVENTF_KEYUP, 0)
End Sub
Thanks
|
|
|
|
|
Does the underscore not require the shift key to have been pressed also?
|
|
|
|
|
I try that too
Private Sub Key_US_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Key_US.Click
SetActiveWindow(8975651603260375040)
keybd_event(VK_SHIFT, 0, 0, 0)
keybd_event(&H5f H2D, 0, 0, 0)
keybd_event(&H5f H2D, 0, KEYEVENTF_KEYUP, 0)
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
|
|
|
|
|
That won't work. The keyboard, not the event system, decides what key is sent when shift is down or not.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That work perfect for the at simble
Private Sub Key_AT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Key_AT.Click
SetActiveWindow(8975651603260375040)
keybd_event(VK_SHIFT, 0, 0, 0)
keybd_event(&H32, 0, 0, 0)
keybd_event(&H32, 0, KEYEVENTF_KEYUP, 0)
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
End Sub
every key worked perfect
|
|
|
|
|
This looks nasty. Why did you do it this way, was it so you could have all control keys working ? You'd do better to store the character you're sending in the tag of the button and write one method to handle all event clicks.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Bob Beaubien wrote: the hex code for it H5F
That is the ASCII code, not the virtual key number.
Bob Beaubien wrote: SetActiveWindow(8975651603260375040)
that is horrible.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Bob Beaubien wrote: SetActiveWindow(8975651603260375040)
You do know that the window handle for any window changes every time you create the window, right?
|
|
|
|
|
Hi Dave
No i dont no that the window handel change every time
so i guess i would have to check what it is every time and then use that ???
Thanks
Bob
|
|
|
|
|
you could use a variable and get the handle's value from Windows based on whatever it is you know about the window (or from the Process class if your app started it)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi,
I have a Windows Form application that runs TopMost. In this application, there is a print function, which silently prints out a PDF file to the default printer.
At the load of the Form, since the TopMost property is set to True, the Start Menu is hidden, which is exactly what I want.
However, when the printing action is launched, the Start Menu pops up. This is triggered by the Taskbar (a little print icon is shown upon printing).
Is there a way to prevent this?
This application needs to run at an exposition, and will be launched on a touchscreen computer. The idea behind this, is that a customer can print a brochure of a product he's interested in.
Secondly, I want to disable all the default shortcut keys to close the application (like ALT + F4, CTRL + ALT + DEL, etc.).
Any ideas anyone?
Kindly yours
|
|
|
|
|
To prevent closing of your application just put e.cancel = true in the formclosing event of your main form.
You can't prevent it from being closed in the taskmanager.
As to keeping the taskbar hidden you can try to put me.bringtofront after the print code but I doubt that it will work.
I don't think there is much you can do against it.
|
|
|
|
|
Isn't there another way around?
Like, an auto closing MessageBox, displaying for example the text "Please wait. Your information is being printed", and when closing the MessageBox, returning to the startup page (which is also defined as TopMost)?
|
|
|
|
|
Visual Studio 2010 beta1 does not contains Crystal Report , any particular reason for that
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Why not ask Microsoft, they will probably know better than the people here
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
tried, i thought beta 2 release might have , plus then what is the use of code project
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
softdev_sup wrote: plus then what is the use of code project
Programming questions perhaps ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Actually i had some projects in vs 2005 in which i used crystal reports , so , if their is no Crystal reports in vs 2010 then i was thinking what to do for older reports should i go for the license for Business Objects etc. Microsoft or any other company will never say they did something wrong anyhow as told by "Dave" it could be bcz of Beta Version.
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Probably because CR is not the product that is in Beta right now?
Just because it's in Beta doesn't mean that your looking at the final retail product package.
|
|
|
|
|