|
I have a database application i wrote to allow me to take notes on c# and enable me to look up the answers at a later time. If anyone is interested in this just shoot me an email and i'll happily send you the application. All i would ask in return is suggestions. In any event, in this application I use crystal reports to display my code snippets and so forth. This is where my question comes in. Once it generates the report for me it appears to be in read only which is perfectly fine however, is there a way to make it where i can copy and paste. This would be benificial to me instead of having to write the source code on line at a time. I know I could make a text box and overlay it so I basically select from the textbox and it appears to be from the report. To me that would be a crappy way of doing it. Any other ideas?
by the way if your interested in that program I mentioned send an email to
REMOVEME_bigt1@comcast.net
thats a one instead of a L
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Reports and read-only for a reason - there's nothing to change. If you're looking for design capabilities at runtime, you need to license (costs mucho $$$) the designer components from Crystal Reports.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have been trying to add data coming from UdpClient onto a datagrid by populating the data into a table and then add it to a DataSet. However, when I bind the data to the DataGrid using DataGrid.SetDataBinding(), I got an error that says "The controls on one thread can not be parented to another control on a different thread". I have searched everywhere for a solution to get around this but haven't found one that would work.
Right now I am using ListView instead but I still like to use DataGrid.
Any of your help is greatly appreciated!
Thanks
|
|
|
|
|
I think you need to use a delegate and an event handler from your UDP code to solve your problem. I don't know if your UDP client generates any events but if not you could always use a timer. You may be checking the UDPclient via a timer anyway.
updateTimer = new System.Timers.Timer();
updateTimer.Elapsed +=new ElapsedEventHandler(UDP_ready);
updateTimer.Interval = 1000;
updateTimer.Start();
and then
public void UDP_ready(Object source, ElapsedEventArgs e)
{
BeginInvoke(new UDPHandler(UDPReadyHandler));
}
public delegate void UDPHandler();
public void UDPReadyHandler()
{
}
There may be a more efficient way of acheiving this but it worked for me in a similar situation. I think you can use variables with the delegate if you need to.
|
|
|
|
|
Thanks again Chris for your suggestion.
I think your solution applies to asynchronous event but for network stream data keep coming in constantly all the time, this method would not work. I tried the test again using a delegate but it still is giving the same whining.
Here is the outline of my code:
DataTable myTable;
DataSet mySet;
FillTableHeaders();
mySet.Tables.Add(myTable);
Thread theadTest = new Thread(new ThreadStart(GetData));
threadTest.Start();
void GetData()
{ FillTableThruUDPConnection();
dataGrid1.SetDataBinding(mySet,"ParentTable");
}
I think there is another internal thread when the datagrid binds the data from a table that I can't seem to find a way or a method that go around the SetDataBinding method. ListView works really well for because it doesn't have have to have another medium to hold the data like the DataTable.
|
|
|
|
|
Hi,
I would like to create a monitor for a server running as an NT Service. The monitor will be visible in the notification area and a context menu will enable starting, stopping restrting (etc.) the server.
I have no idea where to start from . Can you please provide me some reference or general oerview? is it possible at all? I searched the net for IIS monitor, which I know exists but I'm not sure whether only in my organization (perhaps someone there wrote it). Anyway, I couldn't find anything useful.
I didn't write the server so I don't know if it exposes some API. Any reference will be a great kick start.
Thanks.
-------------------------------------------------------------------
* Only drug dealers and computer programmers call their clients 'users'...
* Pardon me for the poor English.
|
|
|
|
|
Extend ServiceBase and create your service if you haven't already. Add an Installer derivative that uses the ServiceInstaller and ServiceProcessInstaller (both optionally if you choose to have another installer do it) that installs it.
When you install the service, you must have it log in as a specific user that has an associated desktop as well as "Log in locally" rights, or install it to run under LocalSystem (SYSTEM) and enabled desktop integration.
Your monitor then can use the ServiceController to communicate with it on a basic level and receive notifications from the service, or you could use named pipes (no support in the .NET FCL), sockets, .NET Remoting (optimal between AppDomains), etc.
Search CodeProject. I'd bet there's a couple examples of something similar, otherwise I'm sure you'll find examples if you google[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you Thank you Thank you ServiceController was the missing keywrod in my searches.
Still left to figure out is how to add the monitor to the notification area and add to it a context menu. I'll search and come back with questions
Bless you
-------------------------------------------------------------------
* Only drug dealers and computer programmers call their clients 'users'...
* Pardon me for the poor English.
|
|
|
|
|
See the documentation for the NotifyIcon component in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Lots of thanks
-------------------------------------------------------------------
* Only drug dealers and computer programmers call their clients 'users'...
* Pardon me for the poor English.
|
|
|
|
|
The last line of code below crashes my program. I am stumped as to why it's happening.
I've double and triple checked the definitions for the BlockCopy and GetBytes functions and I still can't work out what I'm doing wrong. Any insight would be appreciated.
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
int int1 = 3;
int int2 = 1000;
byte[] b = new byte[16];
Buffer.BlockCopy(BitConverter.GetBytes(int1), 0, b, 0, 8);
Buffer.BlockCopy(BitConverter.GetBytes(int2), 0, b, 12, 4);
}
}
}
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
Try the following:
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
int int1 = 3;
int int2 = 1000;
byte[] b = new byte[16];
byte[] b2 = BitConverter.GetBytes(int1);
byte[] b3 = BitConverter.GetBytes(int2);
Buffer.BlockCopy(b2, 0, b, 0, b2.Length);
Buffer.BlockCopy(b3, 0, b, 12, 4);
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
It's a weird problem, eh? The length of both arrays returned from GetBytes() is 4, so I think that it's actually the second-to-last line that's causing the problem with its length of 8. That code must be badly written in the current version of .NET: the second-to-last line above leaves the static stuff in Buffer somehow in an incorrect state, which is exposed by the subsequent call. Sorry I can't be of more help.
Regards,
Jeff Varszegi
|
|
|
|
|
Hi, I'm thinking of writing an extension to the asp.net Datagrid component (as web custom component), mainly to make the tasks that require repetitive coding like updating,insert, delete, easier, but also to add additional functionality.
First of all I was wondering if anyone knows of any open source or free components that already do this? Obviously I don't want to do something that's already been done - the list of goals for the first version are below.
If none is available, would anyone would be interested in helping in the project? The 5 goals I have in mind for the first version are:
- Obviously subclassed from the Datagrid
- IDE wizard for the SQL generation of update,delete,insert (similar to the sqladapater one)
- Automatically adds the insert textboxes in the header/footer, if set in a property
- Automatic handling of edit/delete/insert sql
- Delete confirm message (3 lines of code
- Property to automatically turn edit/delete/add on or off depending on the Context user being authed (also 3 lines of code
Future ideas I have in mind would be to have easy integration of other controls for the edit/insert, besides the standard textboxes, and a few other things.
- Chris
-- www.sloppycode.net --
|
|
|
|
|
You can always check places like http://www.asp.net[^] for existing controls.
One thing you should consider if you develop this yourself is not to re-develop the DataGrid itself, but to encapsulate that in another ASP.NET WebControl . There's a lot of work involved if you re-develop it, which is - as you implied - pointless many times. To have the DataGrid render itself, in your Render override simply pass the HtmlTextWriter to DataGrid.RenderControl (inheritted from WebControl ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
No, my intention was firmly to subclass the Datagrid I've had a browse through sourceforge,asp.net and gotdot.net but couldn't find much. I'm also surprised that there are virtually no freeware/opensource .net forums out there besides the www.gotdotnet.com one. Perhaps the Microsoft community are unscrupulous (sp?) when it comes to people paying for their time.
|
|
|
|
|
There's plenty of free source here on CodeProject and many other places. The definition of "open source" is a very lax one.
Personally, I like to give back to the community by offerring bait, lures, and tackles so that others may learn to fish. I can't think of a single reason to spend my time (and perhaps others') on a commercial grade solution without getting something in return besides a few "thanks" and lots of support requests. People have to eat and shelter themselves. That's just my $0.02 (US) on open source vs. commercial software.
As far as extending the DataGrid , you could do that but you seem to be developing more of a composite control, which it's typically better to encapsulate (in order to control, for one). It'll also make rendering (including placement, etc.) a little easier.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
You can set the IsBackground property of all threads true.
Once all foreground threads belonging to a process have terminated, the common language runtime ends the process by invoking Abort on any background threads that are still alive.
Otherwise use the ApplicationExit event of Application class and abort the threads yourself inside the event handler.
|
|
|
|
|
Another way - albeit it a potentionally dangerous one - is to call Environment.Exit , which unloads the CLR - which unloads your application - immediately. No clean-up code is executed at all and the OS will reclaim memory used by the process. This will stop any execution dead in its tracks.
Another common implementation is to signal threads or have threads query for a "stop" request while running (in a loop, you could do this at the beginning of each iteration, for example). They could then stop themselves gracefully instead of throwing ThreadAbortException s that may be undesirable and often difficult to catch (for more information on that, see the Application.ThreadException or AppDomain.UnhandledException events).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have one minor correction related to what you wrote (although the quality of your advice is as high as ever, don't get me wrong). Calling Environment.Exit() doesn't mean that no clean-up code is executed, just that no normal shutdown code written into the application will be executed. If you run this, you'll probably agree with me:
<br />
using System;<br />
<br />
namespace Test {<br />
<br />
class ExitTest {<br />
<br />
[STAThread]<br />
static void Main(string[] args) {<br />
ExitTest et = new ExitTest();<br />
Environment.Exit(0);<br />
}<br />
<br />
~ExitTest() {<br />
Console.WriteLine( "Destroying..." );<br />
}<br />
}<br />
<br />
}<br />
I think that if someone is going to use Environment.Exit() , it should only be used in emergency situations if they need their code to exit quickly, or to return a specific exit code to the OS (which can also be done using a variant of Main() ). If the case is the former, all objects using important resources should implement destructor methods to make sure that no matter what, they're cleaned up properly.
Regards,
Jeff Varszegi
|
|
|
|
|
Hi everybody!
Last week I received the task to develop and implement a simulation and analysis environment for a flow control algorithm. I have no restrictions for this except that the flow control algorithm will be implemented in C++.
Because i recently worked much with C# and really like it, i want to use this instead of C++. But this of course brings up the question of how to insert the algorithm into the environment.?
How good are the chances to port this algorithm to C# and are there maybe some existing tools?
Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code, because i've read it's no problem to mix programming languages that way.?
Can someone tell me if it's possible what i want to do or give me some suggestions.
Thx in advance!
|
|
|
|
|
Troschi wrote:
Otherwise, i thought of creating a .NET Class Library with the algorithm and use this in my C#-Code
A .NET Class Library is written in any language targeting the CLR, like C#. You could implement this in C#, yes, but .NET itself is not a language - it's a Framework comprised of the Common Language Runtime (CLR), the Common Type System (CTS), and the Common Interface Language (CIL).
If you need to implement the algorithm in C++, consider using the Managed C++ extensions and write it using a mixed-mode assembly. Any language targeting the CLR (like C#, VB.NET, et. al.) can use it like any other assembly written in any other language (it all compiles down to Microsoft Intermediate Language, or MSIL anyway, though native instructions in C/C++ are compiled to native code, making your assembly less portable).
You seem to be a little confused about what .NET is. I suggest you read about the Microsoft .NET Framework[^] to learn more.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for answering.
I know .Net is not a language. Maybe i didn't express myself well by using the term ".NET Class Library". I meant creating a Class Library targeting the CLR which is written in C++.
Anyway, it's good to know that i can use it in languages targeting the CLR. As i said i read about it but never used it until now. Just wanted to be sure it works. Also i will read more about .NET Framework, always had this in mind but never found the time.
Nevertheless I have another question. I don't write the flow control algorithm myself, just the simulation and analysis environment. Therefor I have no real influence on the implementation of the algorithm. I'm a bit afraid that when i want to create the .Net Class Library with the completed algorithm some bad difficulties, incompabilities or so occur. I don't really know how to say this. Any guideline to avoid such things?
Hope i could make myself clear.
|
|
|
|
|
If you can't dictate how the algorithm is developed, don't fret. You have several options: create a MC++ assembly that uses the C/C++ APIs even in a __gc class (managed class declaration). Compile it as an assembly and you'll have no problems.
If the algorithm is comprised of only a few exported functions (hopefully C-style, but C++ name mangling is not really a problem either), then consider writing your wrapper component in C# and just P/Invoke the functions you need, correctly defining any structs and consts you might need to marshal.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|