|
I'm doing development for a C# Windows Forms application. Currently, users are complaining of copy and paste problems on multiple forms. People are unable to copy and paste in some or all areas of the forms. It either throws an exception (see below) or the copy/paste box is grayed out.
System.Threading.ThreadStateException: The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Clipboard.GetDataObject()
at C1.Win.C1Input.C1TextBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I have researched this alot and it seems to be some sort of Windows threading issue. The application is run via No Touch Deployment, which I think defaults to Multi Threaded Apartment, even if you start the app on a STA thread. I have a solution for the copying but I need to know how to hook it up to the Copy / Paste event in Windows forms....Is there a way you can override the Copy and Paste functions in a windows form? For example when you right click on a textbox and choose copy from that little context menu, Can I handle that click event on that menu some how? Could I override the Ctrl C key down call and hook up my own copy??????
This would be of MUCH help!!! Thanks guys
Daniel Gruszka
|
|
|
|
|
I have a couple of DataGridView refreshing problems.
The first one is how to get the datagrid to refresh the data the fastest. I used dataGridView1.Refresh() to refresh the data as it is coming in, but it causes the mouse to lag, without doing the refresh() the mouse and clicking capabilities are fine, but I cant see anything on the DataGridView unless I minimize the window and restore it (or anything that forces the control to redraw. I would like a faster method of updating the data that the DataGridView is using than the dataGridView1.Refresh().
The other problem I am having is when the DataSet table exceeds the size of the DataGridView. The sliders dont show up unless I resize the window. Even the dataGridView1.Refresh() doesn't update that. I want a way to explicitly tell the DataGridView that the size of the DataSet has exceeded its control size.
Any advice or help is much appreciated.
|
|
|
|
|
Well you hit it on the head, the refresh forces the repaint. When you minimize and resize it does pretty much the same thing.
I know of no other alternative than a refresh.
Are you populating the data in the grid in the same form? Is it a long operation to get the data? Watch out for a long operations in any method of the main form, it causes delays in the repaint logic. The application acts like it's dead for a while.
You can use delegates, and invoke.required checks to make it work better if it's a long operation.
|
|
|
|
|
Are you binding a DataGridView directly to a DataSet table instead of going through a BindingSource?
--
I've killed again, haven't I?
|
|
|
|
|
hello all,
I have been trying to make a program to shutdown my computer, i have the program on a timer and at a certian time i would like the program to shutdown my whole computer. i am planning on using it for when i am Burning dvds or listening to music before bed.
i know that the command prompt has a command to shutdown a computer:
/shutdown -s
where u can also use [-t XX] where XX is the time till it shutdowns.
Can someone please help me in this, either by using C to open and use command prompt by itself, or another way.
Thank you Very much.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
In C#, you could simply call:
System.Diagnostic.Process.Start("shutdown.exe", "-s -f -t 00");
For more info, check this out: click here.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Thank you so so very much.
First time using this site and very impressed with the quick responce.
Thank you Jun Du.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
You're welcome. Glad my answer is helpful.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Sorry to bother u even more, i ams ure u are very busy.
but if it isn't to difficult, is there a way to send the app to my notification area? Atm it is on my taskbar. If this requires a lot of coding and is very difficult please just skip this i do not want you to spend all your time on me. Thank you very much Jun Du.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
oh sorry again, just at work atm and can not try out that code string u recommended i try. That is striaght C code right?
Sorry if this is a dumb question, i am new to C coding and only been doing it for about 8 month.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
No. That was C# code. IF you're writing plain C you need to be asking in the c/c++ forum. C#'s a completely seperate language.
|
|
|
|
|
Thank you, i was hoping it would be similar. thank you.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
Though you are in the wrong forum, I will try. First of all, why this obsession with C? Why not a BAT file that has "/shutdown -s" typed in it, and use Windows Scheduler to run it whenevr you want?
OK, so you are the "I will write my own program" kind of addict. Why not use the WinExec() Win32 API to execute the same BAT file? Create the BAT file and keep it somewhere on the hard disk. Now in the C program (which can take parameters like timer duration etc - that is your design, you can even pass the full path & name of theBAT file if you want your program to be generic) that will simply execute the BAT file at the specified time.
Koushik Biswas
|
|
|
|
|
I am trying install my pc Reporting Service with Report Server and Report Manager. But an error occured when I install this program. I had installed SQL Server 2000 Developer Edition in my PC.
The error is:
"This edition of Report Server Database is not supported on edition of SQL Server 2000 you have chosen. Please choose another SQL Server that matches the requirements. "
What do I do? Please help....
Thank you...
This is my sign
|
|
|
|
|
I think you can check the reporting service requirement .It needs sql server 2000 with server pack3
|
|
|
|
|
Hi,
Scenario is
I have
=> App1 version 1.0 (developed with framework 1.1)
=> App1 version 2.0 (developed with framework 1.1)
now when i install version 1.0 into any machine it installs some files to GAC and to bin folders. At the same time i want to install App1 2.0, which also installs assemblies to GAC and same bin folder of 1.0 (target Installation path is same).
Will there be any problem running two versions parallally. My assumption is if two different versions have strong named assemblies with version numbers, there should be any problem, Any views pls welcome
kumar
|
|
|
|
|
Don't know for sure, but to be safe, put one in a different namespace.
|
|
|
|
|
I can't put in different namespace. Any other solution?
kumar
|
|
|
|
|
Well you can just fire them up and see what happens. Watch out for static fields. They will always be shared.
|
|
|
|
|
Mr. VB.NET wrote: Well you can just fire them up and see what happens. Watch out for static fields. They will always be shared.
Static fields are only shared between objects within the same process (maybe even limited to AppDomains - never tried this). As two applications are always started in separate processes, there will be no interference due to static fields.
|
|
|
|
|
As long as the assembly version numbers are different, there shouldnt be any problems
|
|
|
|
|
Hello,
I'm making a windows form app using c#. In one form, I am "Painting" a table in a panel. When a button on the form is clicked, I would like to repaint the panel using specified parameters. Does anybody know how to do this? Here is some of the code:
private void goBtn_Click(object sender, EventArgs e)
{
pltNum = pltList.SelectedIndex;
tblPanel_Paint(object sender, PaintEventArgs e);
}
I guess I'm not sure what parameters I should pass to the tblPanel_Paint method.
Thanks for your help!
RC
|
|
|
|
|
RC,
To force the Windows Form to redraw, you should use the Invalidate function, rather than calling the paint event handler directly. For information on that function, have a look at Control.Invalidate[^] from MSDN.
The important thing to note about the Invalidate function in that article is this sentence:
"Calling the Invalidate method does not force a synchronous paint; to force a synchronous paint, call the Update method after calling the Invalidate method. When this method is called with no parameters, the entire client area is added to the update region."
This simply means that when the Invalidate function returns, the control has not necessarily been redrawn yet. Thus it is possible that, after the user has clicked your "Go" button, the form does not redraw itself (although in normal usage, you won't really be able to tell). Nevertheless, as the MSDN documentation says, to force the redraw immediately, simply call the Update function after you call Invalidate .
Here is how your code would look:
private void goBtn_Click(object sender, EventArgs e)
{
pltNum = pltList.SelectedIndex;
this.Invalidate();
this.Update()
} Let me know if that works for you, or if you still have a difficulty, I will try to help you as best I can.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Hi Alexander,
The invalidate method worked! Thanks for your help!!
RC
|
|
|
|
|
Anyone care to take up a discussion on GoF patterns? I am just getting into it now and want to learn more about it.
Found out, I've been using the facade pattern without knowing the name of it for some time now. I am finding the study of this is both simple and complex. It has a lot of depth to it and I don't find a ton of C# examples out there.
First question: How does one start to use patterns, you read about them etc. but How do you take a design requirement and start the process?
|
|
|
|