I'm working on a VB6 project and I cam across something that I'm unable to resolve. In my project I'm using 2.0 comboboxes. Everything works fine, in terms of loading the combobox with data, selecting it, and the whole bunch. What I'm trying to do is, once data has been selected, I'm making sure that the same data has not been selected in both comboboxes. I'm trying to write a quick comparison IF statement in LOST FOCUS for one of the cbo's but it doesn't seem to work.
Private Sub cbo1_LostFocus()
if cbo1.text<>"" and cbo2.text<>"" then
if cbo1.text = cbo2.text then
MSGBOX "Duplicate Values"
else
exit sub
End if
end if
End Sub
it doesn't at all realize there is LOST FOCUS - I don't think I've ever done that to a cbo, usually textboxes and such. Any help is appreciated.
You could try GotFocus instead. It seems the LostFoucs event can be overridden or masked in certain cases. This article shows a similar problem: http://www.vbforums.com/showthread.php?396536-RESOLVED-VB6-LostFocus
Of course, you could always upgrade to the latest VB, but I'm guessing you have your reasons.
Related
I should start out with the disclaimer that I don't have a lot of info into this problem, but I wanted to put a feeler out to see if anyone else had this problem. I started a new job and some folks here are using Infragistics WPF datagrid. The grid was selected because of the visual flexibility, but apparently when there are large amounts of rows in the grid, things begin to perform very poorly. This is possibly due to implementation (not sure, haven't gotten into the code yet) and shouldn't be taken as a negative on the control.
Has anyone else encountered and have any advice I could pass onto the developers? Thanks in advance.
Edit*: I think introducing paging might not be an option. The grid is being used in such a capacity that it is displaying data streamed into it. So the use case is that the end user is monitoring 50-100 rows that are updating with new values intra-second (aka - think running stock tickers instead of flipping through a result set)
I'm having problems with XamDataGrid as well. Although I don't have the right version to attempt this, you might try changing to the high-performance hoverless style, and suppressing events, as described here:
http://blogs.infragistics.com/forums/p/48307/264160.aspx
The rest of the suggestions are a lot more specific and handle particular schemas and use-cases.
Here's a bit more of an overview of Infragistics optimizations:
http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamData_Performance_Optimizations_Overview.html
I am using the Xceed DataGrid, but I recently discovered our DataGrid was binding to a View (DataGridCollectionView) and not to a datasource (DataView/DataTable).
This meant we replaced the entire view for each refresh.
By binding to a DataTable, my code now refreshes the DataGrid instantly with a few thousand rows where it use to take 1-2 seconds.
As most grids are similar. please verify how your code is binding to the data that goes into your DataGrid.
I posted some code here in case that helps.
The approach is take is to enable virtualisation - this ensure that only the information on the screen is involved in a repaint. See no problem with 100 rows being continuously updated.
I am using the vanilla datepicker in Silverlight 2. I bind the selected date to a value, and when that value changes I pop a messagebox to confirm that they would like to change the value.
However strange behaviour ensues when I use a messagebox straight after the datepicker's value is changed. The datepicker's popup will not close, and if you mouse over the calendar it will choose a date without having to click the mouse.
Also, after this occurs it seems to affect bindings and it cannot set the view model's property again until the page is reloaded.
This problem is rather specific so I have attached a stripped down example. Choose a date and press OK then move your mouse over the calendar to reproduce this.
My XAML -
<Grid x:Name="LayoutRoot">
<controls:DatePicker x:Name="dpTest"
Height="25"
Width="75"
SelectedDateChanged="DatePicker_SelectedDateChanged" />
</Grid>
My code behind -
Private Sub DatePicker_SelectedDateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
MessageBox.Show("Test Popup")
End Sub
Any ideas or workarounds?
Hmm this is not all that uncommon actually. A coworker of mine recently ran into very strange issues in a Windows Forms application because he was using MessageBox in response to a third party menu control's click event (before the menu had been dismissed.)
One suggestion that didn't work for him but may very well work for you is to "push" the call onto the dispatcher. That way your SelectedDateChanged handler will return before the message box actually gets shown.
Private Sub DatePicker_SelectedDateChanged( ... )
' Unfortunately my VB is rusty '
' I believe this is the correct syntax. '
Dispatcher.BeginInvoke(AddressOf ShowDateMessage)
' At this point, the message box has *not* been shown '
' It will be shown once control returns to the dispatcher '
End Sub
Private Sub ShowDateMessage()
' By this point, the DatePicker popup should be closed '
' so hopefully the issues you are seeing would be avoided '
MessageBox.Show("Test Popup")
End Sub
A couple of things to keep in mind though:
MessageBox.Show is unique in Silverlight in that it is one of the only ways to create a modal dialog. And unlike in Windows Forms where the message loop is still running, Silverlight's UI thread is stalled until it returns.
The event already takes place after the date has changed so this is not a good way to confirm the change. A cursory glance at the docs suggests there isn't a corresponding "Changing" event.
Depending on the circumstances, you might just be better off using a ChildWindow instead of MessageBox. This wouldn't have the issues you described because while it appears to be a modal dialog, it's not.
I blogged a workaround HERE that make the message box unnecessary by changing the work flow.
In an SL3 datagrid, is it possible to have every cell of the grid editable?
I need to create a UI that's similar to an Excel worksheet. Upon a button click, the entire collection of objects would be submitted as opposed a single object or cell.
Is this even possible, and if so how would I go about achieving it?
Thanks.
I guess the reason why this question has sat here 4 hours with no answer is that we all asking ourselves "Have I missed the problem here?".
First of all you can't actually "edit every cell concurrently", after all when you hit a key on the keyboard only one control is going accept that is input, the one with the focus.
"Excel worksheet" behaviour is exactly what you get from DataGrid if you let it automatically generate the cells.
So this question is really about the object you assign to the ItemsSource property. You really need to tell us about what you are using to store the data.
The truth is your requirement is quite easy to deliver especially if you include WCF RIA services. Ulitmately you get a "Data Context" which you can edit in various ways and then submit changes at whatever point makes sense for your application.
so basically I have an AddCompany Form, where theres a textbox [CompanyName], i want to type a new company name in there, but meanwhile check if theres an already existing one.
So for example,say i want to type Microsoft, when i type M, the textbox shows whole bunch of other names with M, and then keeps going until I type finish typing microsoft. Basically jsut how the facebook search box works.
How do i implement this on Microsoft Access 2007?? could it be in the on dirty event/on change/On key down event???
please enlighten me!!
Thank you very much!!!
A much simpler version of the same thing can be done with the Access wizards. If you turn on the form wizards in form design and click the Combo Box button and point to a location in the header of your form, you'll automatically get a choice to create a combo box that will look up a record that matches something listed in the dropdown list.
However, keep these things in mind:
it works only when you've bound your form to an entire table (which is not recommended for large recordsets)
the code it creates is horrendously BAD.
There are a number of ways to solve this problem. If you're happy binding your form to the entire table, bookmark navigation (as with the code created by the wizard) will be fine. However, I recommend you use this code instead of the wizard code (assumes the combo box has a bound column with the PK ID of the record you're trying to find):
Private Sub MyComboBox_AfterUpdate()
If IsNull(Me!MyComboBox) Then Exit Sub
With Me.RecordsetClone
.FindFirst "[MyID]=" & Me!MyCombBox
If Not .NoMatch Then
If Me.Dirty Then Me.Dirty = False
Me.Bookmark = .Bookmark
End If
End With
End Sub
The combo box would need to use a SQL rowsource, and it would be something like:
SELECT CompanyID, CompanyName FROM Company ORDER BY CompanyName
And you'd define the combo box to have 2 columns, the first one the bound column, and you'd set the width for the first column to 0. The wizard walk you through doing this and set it up for you. The only thing it does wrong is write really bad code to do so.
Now, if you're not searching for a unique value, it gets more complicated, and you might want to use a different approach. Suppose you have a form that displays people and you want to see the ones for a particular company. In that case, you might want to filter by CompanyName. In that case, instead of doing a Find operation as outlined above, you might want to apply a filter. In that case the AfterUpdate event of your combo box would be something like this:
Private Sub MyComboBox_AfterUpdate()
If IsNull(Me!MyComboBox) Then Exit Sub
Me.Filter = "[CompanyName]=" & Chr(34) & Me!MyComboBox & Chr(34)
Me.FilterOn = True
End Sub
Now, in that case, your combo box would have but one column, with the company name and no hidden ID field, so it's somewhat different.
I don't like programming this kind of filtering as it's provided by the Access UI (you can right click on the CompanyName field and in the shortcut menu that pops up, type in the company name you want to filter for, including wildcards, ? and *). Also, it can get confusing when you try to filter when there's already a filter in place. If you're viewing just CitiCorp and then you filter by JP Morgan Chase, you won't get anything.
Instead, I'll tend to change the Recordsource of the form instead of applying a filter. This means each search will give you a new resultset and is the most efficient approach. It does make things a little bit more complicated in terms of returning to your original starting point, but in a properly-designed app, you should probably be presenting only subsets of data to the users in the first place, so the problem this approach "causes" is one that you'd need to resolve to build a proper and efficient user interface that retrieves only the data that the user really needs.
In general, this feature is called auto-completion (I've also heard find-as-you-type). There is an article giving an example of how to do this in Access on this page.
The forms in Access have event handler functions. So couldn't you use autocompletion code added to these functions for this functionality? I found a book on Google Books which discusses this.
I can think of the following code which would need to be added to the event handler function:
1. SQL to find existing potential matches
2. Code generated drop-down box to display potential matches
I have found the following in WPF:
I have a form with AllowTransparency=true. Inside the form I put a Combobox.
I add some items to the combobox.
I run this application and click on the combobox. At first it does not seem to appear at all. On closer inspection (after adding more items) I see that it is actually appearing behind the form. If I add enough items it become visible from behind the form.
If I just change AllowTransparency=false, then all is fine.
This looks like a bug in WPF (3.5 SP1).
Any one know of a workaround for this?
Go to
https://connect.microsoft.com/dashboard/?wa=wsignin1.0
submit your feedback after searching #
https://connect.microsoft.com/VisualStudio
https://connect.microsoft.com/VisualStudio/feedback/CreateFeedbackForm.aspx?FeedbackFormConfigurationID=1160&FeedbackType=1
and mention steps to reproduce.
There was an update of 3.5sp1 but you could test,but I doubt
http://www.microsoft.com/downloads/details.aspx?familyid=6c095bba-6100-4ec9-9c54-6450b0212565&displaylang=en
AllowTransparency is slow and buggy and shouldn't be used - it's a great way to run into bug in various display drivers.
You can get almost anything you like without using AllowTrasparency, take a look at this post for examples:
http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx