|
Hello All,
I am creating a xml file programatically but it is saved as .dtl.
I have no Idea how to assign a ICON to saved file.
Plz guide me.
Thanks in advance
|
|
|
|
|
And I assume you want to do this programmatically? Check out this[^] CP article.
|
|
|
|
|
Thanks for your Reply.
Is ther any dot net APi to do so?
|
|
|
|
|
Is there on codeproject or other introductory articles on technical issues in C# application development and deployment with MS SQL express 2005/2008? like db creation and attachment to application with connection strings for SQL authorization, setting folders security to access it with SQL authorization from application and finally deployment from setup?
Чесноков
|
|
|
|
|
Hi......
I am having problems while connecting to Vector CANdb database file in C#.Net. It gives an error
"Object or provider is not capable of performing requested operation"
So, how to achieve it?
Thank you.
|
|
|
|
|
Hi,
how do try to connect to the DB? Could you post the code? I guess that you are using the wrong client library.
Regards
Sebastian
|
|
|
|
|
You proably don't have a provider installed that supports CANdb databases.
You'll either need to find a provider that supports that database format or a library that handles all database access for you. I don't know of any.
|
|
|
|
|
Hi,
i have a windows service having a udp server, tcp server and a serial server all acquiring GPS data from remote devices. After data is acquired it is parsed for validity and processed into defined objects. Now this data has to be relayed to multiple client UI's which can be running on a local or a remote machine. Previously i used MSMQ for data sharing between different processes but i seem to be having some problem with connecting to remote machines. So i decided to switch to .net remoting. Its my first take on remoting so kindly bare with me.
I have to share that real-time parsed objects with multiple clients with minimum latency.
The channel between server and client should allow 2-way communication between client and server in the form of a string and objects.
I wish to inquire which type of object activation should i use.
Thanks in advance.
|
|
|
|
|
isso é bem simples, basta declarar um vetor com ponteiro multiplo e chamar o método Add() dentro do seu ânus
|
|
|
|
|
Hi everyone,
I am trying to update some UI periodically through the use of Application.DoEvents() in response to a timer callback. However, I am having a bit of trouble getting it to work.
So, I have a dialog box that is created in the main thread. I have a long running method in a third party control and all I want to do is make sure that the dialog box stays responsive to mouse movements and can respond to move events etc. I know I should be calling the long running function in a background thread but due to the idiosyncracies of the software design and third party tools, I am unable to do so.
So what I thought I would do is create a Threading.Timer object and have it send periodic events to my dialog box and ask the message queue to process the messages.
This scenario is as follows:
m_timer = new System.Threading.Timer(new TimerCallback(TimeElapsedHandler),
null, System.Threading.Timeout.Infinite, 100);
m_timer.Change(0, 100);
The timer handler is as follows:
private void TimeElapsedHandler(object state)
{
System.Windows.Forms.Application.DoEvents();
}
In the debug mode, I can see this event getting called during the processing. However, the DoEvents() call is not really updating the dialog box as it should.
Now, the strange thing is that when I add some Application.DoEvents() in the callbacks that I get from the third party call, the update is as I would expect it (I cannot rely on these updates to come frequently enough, hence I need a regular periodic solution).
The puzzling thing is that the timer and the dialog box is created on the main thread. So, I am puzzled as to why my update is not happening.
I would appreciate any thoughts or input you might have on this.
Best wishes,
Keith
|
|
|
|
|
Ok, it seems that the callbacks are from another thread..
I called Invoke and tried to update using that but this, of course, just gets queued and never gets fired till the long running method returns.
Any thoughts anyone?
Thanks,
Keith
|
|
|
|
|
That is not right at all.
1.
All asynchronous events get handled by one or more different threads, never by the main (aka GUI) thread. See here[^]. And such thread cannot help the GUI.
2.
Application.DoEvents() is evil. There is hardly any situation where its use is justified.
3.
What you need to do is keep the main thread free, which means never let it execute anything that takes (or potentially could take) more than some 20 msec. Everything that takes longer, or has to wait, or could get delayed, should be handled by a separate thread (a Thread, a ThreadPool thread, a BackgroundWorker).
4.
And when such thread needs to touch the GUI, use the InvokeRequired/Invoke pattern. See here[^].
|
|
|
|
|
You are, of course, right. I will need to somehow push this task into a background thread.
Thanks,
Keith
|
|
|
|
|
you're welcome.
|
|
|
|
|
Hello,
I have a combo box that is bound to a dictionary item.
dictonary"<"Guid, string">" m_test = new dictonary"<"Guid, string">"();
then on my windows form I have a combo box cboUser
cboUser.DisplayMember = "Value";
cboUser.ValueMember = "Key";
cboUser.DataSource = new BindingSource(m_test, null);
In m_test I do not have any blank entries and if possible I would like to keep blanks out.
The combo boxes are filling in as expected. But it is filling in the text with the first entry. This is causing the modified flag to be set to true. If it were blank the flag would not get set so if the user tries to close and no changes were made then it would close without prompting for save.
Thanks
|
|
|
|
|
It really depends which technology you are using, i.e. is it WinForms or Web Forms. You should be able to insert a new item into the cboUser.Items collection at position 0 which does what you want.
|
|
|
|
|
It is a winforms app.
Tried your idea but the issue when you have a data source set it comes back with an error. Cannot modify collection while datasource property is set....
Tried inserting the item prior to setting the datasource but still same issue.
|
|
|
|
|
OK - as it's WinForms, you need to update the dictionary just before you bind it in. Just add m_test.Insert(Guid.NewGuid(), " "); before you bind the items in.
|
|
|
|
|
I'm trying to use reflection to generate a report from my classes. The trouble comes with class fields that are lists of other, smaller, classes that will be reported as tables. I can isolate those fields using properties ([ReportAttribute("GenerateTable")] )in my class definitions, and get the next layer down with:
foreach (FieldInfo fi in FieldsThatAreLists)
{
IList list = (IList)fi.GetValue(this);
if (list[0] is MyClass)
{
List<MyClass> templist = ((List<MyClass>)list).OrderBy(mc=>mc.Index).ToList();
list = (IList)newlist;
}
else if (repeat for every possible class...)
ReportGenerate(list);
}
Since all of my (smaller) classes have a property called "Index", is it possible to eliminate the maintenance crushing if (list[0] is MyClass) ... with something more elegant?
And once that's done, the ReportGenerate() method needs to sort the order of things in each class to get the report columns straight. I'm working on doing this with more properties in each class definition, but is there a simpler way?
|
|
|
|
|
Make all of your smaller classes implement a common interface:
public interface IIndexedList
{
int Index { get; }
}
That way, you can just test for IIndexedList, and cast to that.
As for your next question... You can sort by anything, not just a single property. When you specify mc=>mc.Index , you're defining a function that takes mc as an argument and returns mc.Index. You could return anything you want, as long as OrderBy can sort it... Number, string, date, etc.
|
|
|
|
|
Thanks, Ian. I'll take a look at interfaces.
My second question is about controlling the order of class properties returned when reflecting. I need to see the fields themselves to set up columns into which the values will eventually be placed. I can make it work by adding a property declaration for each field, but I was wondering if there's something else available with reflection to control the order in which fields are returned.
It seems to depend on inheritance order followed by position within the class declaration, but I can't find it documented so I don't want to depend on it, and in any event, the inheritance ordering messes it up for my case.
|
|
|
|
|
As far as I know, you can't control what order they come back in, so either you sort it yourself based on name or type, or you tag them with attributes.
|
|
|
|
|
I think I've got the interface working, and the test works:
if(list[0] is IIndexedListItem) .
I'm getting an InvalidCastException when I try to cast the list:
List<IIndexedListItem> newlist = (List<IIndexedListItem>)list;
Instead, I tried:
List<IIndexedListItem> newlist = new List<IIndexedListItem>();
foreach(IIndexedListItem item in list)
{
newlist.Add(item);
}
newlist = newlist.OrderBy(p => p.Index).ToList();
This does what I need, so I'm back to work, I just wonder if I'm missing something easy about casting the lists.
|
|
|
|
|
Try list.Cast<IIndexedListItem>()
|
|
|
|
|
If you don't want to use all that fancy LINQ stuff, you can use List.ConvertAll to convert from a list of one type to a list of another type:
List<Animal> myAnimals = (new List<Dog> { new Dog() }).ConvertAll<Animal>(delegate(Dog d) { return d; });
|
|
|
|