|
I guess the Controls (DGVs) that haven't been visible yet (those not on the first tab page) still haven't been rendered at all; so clicking on a tab will first cause the DGV to be actually created (including its Handle property), then the data being loaded into it.
You could force this to happen sooner, IIRC reading Control.Handle suffices to make sure it really exists. Of course adding this to your Form.Load (or Shown) event will postpone its rendering of everything, including the first tab.
A better way to handle the situation could be this, and I would recommend it anyway whenever the database accesses might take more than a second:
- launch a thread to access the database, do not touch the Controls from that thread;
- in the mean time, make sure all Controls really exist (Handle!);
- when the database thread is done, make it signal the GUI thread and start showing the data.
A BackgroundWorker would be good, having the DB stuff in its DoWork and the show-in-GUI stuff in its RunWorkercompleted handler.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
It's the grids doing it, not the database access as such.
If you can "page" the results for the grids, only loading as many rows as will be displayed, it should speed up a bit.
..and water fell from the sky like rain.
|
|
|
|
|
I'm writing a program that uses net framework 4. another person will use this program in his own computer. Is it necessary for he/she to have net framework 4 installed in his/her computer? which version he/she will require?
Thanks,
Sia swar
Baluch
|
|
|
|
|
If you build it to run on .Net 4, the target machine will need to have .Net 4 installed.
Will Rogers never met me.
|
|
|
|
|
They will need .NET installed on there machine. Framework 4.0 will be required. It must also be a Windows operating system and in fact if it is Windows 7, it should have it already installed.
Best to create a installation for your app that will handle the dependency for .NET. Test the installation before releasing.
It shouldn't be a big deal.
"You get that on the big jobs."
|
|
|
|
|
FYI: some 8 months ago my then new Win7 laptop had all .NET versions installed up to 3.5, I had to install 4.0 myself.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I forgot it was just a recommended update for Windows 7 and Vista. So in most cases .NET 4 will be installed on Windows 7 but not all.
"You get that on the big jobs."
|
|
|
|
|
Yes they will require Framework 4.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
I went for a job interview a while ago and failed on this question. I have researched it but can not find a definitive answer. Can someone point me to definitive documentation which clearly explains disposing of objects which have subscribed or registered events.
If the GC attempts to collect ClassA and finds it subscribes to an event of ClassB. Will ClassA be removed from memory?
If the GC attempts to collect ClassB and finds ClassA subscribes to an event of ClassB. Will ClassB be removed from memory?
I was not aware of this issue but the person interviewing me seemed concerned. At the end of the day, I don't care, I'd just like to find out what the truth is regarding eventing and disposing of objects.
"You get that on the big jobs."
|
|
|
|
|
The question to ask yourself is: who is referencing whom?
In both cases it is classB's event member that holds a reference to classA.
Robert Croll wrote: If the GC attempts to collect ClassB and finds ClassA subscribes to an event of ClassB. Will ClassB be removed from memory?
the subscription does not influence the life of classB, so it can be collected if it isn't alive anymore.
Robert Croll wrote: If the GC attempts to collect ClassA and finds it subscribes to an event of ClassB. Will ClassA be removed from memory?
the subscription keeps classA alive for as long as classB is alive.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Robert Croll wrote: If the GC attempts to collect ClassA and finds it subscribes to an event of ClassB. Will ClassA be removed from memory?
If the GC attempts to collect ClassB and finds ClassA subscribes to an event of ClassB. Will ClassB be removed from memory?
That depends. Can they be reached by following references from "any" variable? If not, both will be removed from memory - if they're not static classes, that is
Robert Croll wrote: I was not aware of this issue but the person interviewing me seemed concerned
..next time, ask for the answer and why he choose that particular question.
It wouldn't make much sense to keep the answer a secret; you can find a huge amount of documentation with Google - it would merely prove that you interviewer knows how to differentiate between a correct answer (like Luc's) and a technical correct but completely useless answer (like mine).
..and you wanna know why he choose that question. Did they have a history of leaking things? It puts the interviewer in a defending position, giving you a few seconds to breathe and to collect your mind
I are Troll
|
|
|
|
|
Thanks Eddy,
Both you and Luc have helped. The reason I asked was you also find a lot of misinformation on Google as well. But you have pointed me in the right direction. I think I'll be implementing weak events in future.
BTW I like your approach to interview questions. I'll have to remember that
"You get that on the big jobs."
|
|
|
|
|
This is the reason if u register explicit events handlers at start , you should release them at end.
|
|
|
|
|
Im trying to work with the Listview groups, and I added of course my groups, but im curious why "Default" keeps showing at the top, anyone know why?
|
|
|
|
|
Herboren wrote: im curious why "Default" keeps showing at the top
Probably because it's not part of the Groups collection;
All items should be assigned to groups before they are displayed. Any items that are not assigned to a group will appear in the default group, which has the header label "DefaultGroup{0}". The default group is not contained in the Groups collection, and cannot be altered. It is primarily useful in debugging to ensure that all items have been properly added to groups.
I are Troll
|
|
|
|
|
Hi Experts,
in an application I have business objects with properties, some of which are enumerations. To edit those properties, I inserted a PropertyGrid.
Now I have to localize the UI and therefore the enumeration name and its values, too.
The enumeration name already works well implementing ICustomTypeDescriptor.
For the enumeration values, the tool of choice seems to be deriving a class from TypeConverter. I did so and overrode
- CanConvertFrom
- ConvertFrom (just calling base class, at the moment)
- CanConvertTo
- ConvertTo
The initial value now is translated as requested. But the DropDown list doesn't drop down any longer. There is no small arrow pointing down when clicking on that initial value, as I was used to.
Do I have to override yet another method (something like GetMeThosePossibleValues(), maybe)?
Or does anyone have another idea?
Ciao,
luker
-- Modified Friday, February 4, 2011 6:11 AM
|
|
|
|
|
lukeer wrote: But the DropDown list doesn't drop down any longer.
Did you decorate your property with the TypeConverter-attribute, pointing to your customized converter?
I are Troll
|
|
|
|
|
Yes, I did. And since then it is that the standard entry is being translated but the arrow button indicating a drop down list is missing.
I can get the arrow button back by decorating with an additional UITypeEditor. That UITypeEditor's GetEditStyle() method is to return UITypeEditorEditStyle.DropDown regardless of its context.
But it won't drop down anyways even with that arrow button visible.
And another dropdown, this one without TypeConverter doesn't drop down either. Since this sounds confusing even to me, maybe the following table can help:
| UITypeEditor | No UITypeEditor
-----------------+----------------------------------+-----------------------------
TypeConverter | Arrow Button without | No arrow button
| function | at all
-----------------|----------------------------------+-----------------------------
No TypeConverter | Arrow Button without | DropDown works, but
| function (Function can | without Translation
| be achieved by |
| UITypeEditor.GetEditStyle() |
| returning |
| UITypeEditorEditStyle.None) |
Can anyone please explain this behaviour?
Ciao,
luker
|
|
|
|
|
lukeer wrote: Yes, I did. And since then it is that the standard entry is being translated but the arrow button indicating a drop down list is missing.
Aight, we'll need some code. Can you post a short snippet that displays this behavior?
lukeer wrote: but the arrow button indicating a drop down list is missing.
Sounds like it recognizes the GetStandardValuesSupported (returning true, to indicate that the converter has a list with options to choose from) and not the GetStandardValues method that provides the actual list. If you post your converter here, we'll have a look
lukeer wrote: I can get the arrow button back by decorating with an additional UITypeEditor. That UITypeEditor's GetEditStyle() method is to return UITypeEditorEditStyle.DropDown regardless of its context.
I'd remove the code for the UITupeEditor and focus on the TypeConverter. You should be able to get a dropdown-list using the TypeConverter, if the TypeConverter can be found and the correct property is decorated.
lukeer wrote: And another dropdown, this one without TypeConverter doesn't drop down either.
That sounds logical; nor the UITypeEditor nor the TypeConverter can give it a list with values, hence a dropdown would always be empty.
In the meantime, you might want to check out the walkthrough on MSDN[^]. The second example sounds like what you're building, you might find something if you compare it with your own code.
I are Troll
|
|
|
|
|
Here is my TypeConverter code. As you will see neither GetStandardValuesSupported nor GetStandardValues are overridden yet. Would that be necessary?
public class TranslationTypeConverter : System.ComponentModel.TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType.Equals(typeof(string)))
return (true);
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType.Equals(typeof(string)))
{
Type typeToConvert = context.PropertyDescriptor.PropertyType;
string tableName = typeToConvert.DeclaringType.FullName;
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(tableName, typeToConvert.Assembly);
string key = typeToConvert.Name + "_" + value.ToString();
string convertedString = rm.GetString(key);
if (
convertedString == null
|| convertedString.Length <= 0
)
convertedString = value.ToString();
return (convertedString);
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType.Equals(typeof(string)))
return (true);
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
return (base.ConvertFrom(context, culture, value));
}
}
Ciao,
luker
|
|
|
|
|
lukeer wrote: As you will see neither GetStandardValuesSupported nor GetStandardValues are overridden yet. Would that be necessary?
Yup. The first one explains that it has default values (should return 'true') and that it requires a dropdown-arrow to open the list with those default values. The second method should provide that list with values.
Without those methods, the typeconverter won't show a dropdownlist, as it doesn't know what to display
I are Troll
|
|
|
|
|
What I don't understand is that by not overriding GetStandardValuesSupported and GetStandardValues I suspect the base class to take care of them.
Why doesn't the base class make PropertyGrid show a drop down list while without applying my derived class at all it works?
Ciao,
luker
|
|
|
|
|
lukeer wrote: What I don't understand is that by not overriding GetStandardValuesSupported and GetStandardValues I suspect the base class to take care of them.
If you want a dropdownlist, you'll need to override them. Check the example on the MSDN-page that I linked.
lukeer wrote: Why doesn't the base class make PropertyGrid show a drop down list while without applying my derived class at all it works?
Because a property-grid is intelligent, and it knows that it should use an EnumConverter[^] if nothing is provided
I are Troll
|
|
|
|
|
Thanks a lot.
With overriding the following 6 methods
GetStandardValuesSupported()<br />
GetStandardValues()<br />
CanConvertFrom()<br />
ConvertFrom()<br />
CanConvertTo()<br />
ConvertTo()
everything works as expected.
Ciao,
luker
|
|
|
|
|
Folks
Engaging in a project as a newbie in soundscan, encountered problems while implementing this simple piece of code. It's my appreciation if you lead me through this dense un-documented forest by microsoft !!
P.S.1 : Please introduce me a cook-book or any useful tutorial or documentation in directsound what i couldn't find it anywhere!!!
P.S.2:You can also find the code here:http://www.4shared.com/get/j0J8g6wA/SSM-VBNET-DirectSound.html[^]
Tnx .
#Region "References"
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectSound
Imports System.Threading
#End Region
Friend Class frm_main
...
#Region "Command Button"
Private Sub cmd_capture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_capture.Click
Try
If Not devices_waveformat() Then Return
DSBuffer.Start(False)
Thread.Sleep((DSSamples / DSFrequency) * 1000)
'Containing Input Data
Dim DSArray As Array = DSBuffer.Read(0, Type.GetType("Integer"), LockFlag.FromWriteCursor, DSFormatArray)
DSBuffer.Stop()
Catch ex As Exception
Debug.WriteLine(ex.Message)
Debug.WriteLine(ex.ToString)
End Try
End Sub
#End Region
...
End Class
|
|
|
|