|
Thanks for the help.
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Hi All,
We want to use sql server reporting services (ssrs), but want to create our own viewer and print buttons. Does anyone know of an article that shows how to do this. We really need to create a dll that can be called that will print our reports. Any info would be appreciated.
later,
Clyde
|
|
|
|
|
Here is task at hand:
I need to create a help system that allows users to hit F1 on any field, and they will get a popup explaining the use of the field. Assume that I know how to capture the keyboard event. I have a seperate class that has all functionailty of the HtmlHelp API in it. I need to call the HH_DISPLAY_TEXT_POPUP command. which takes the following structure for input: HH_POPUP as well as the location of the .chm file. I am getting confused as to how I define a structure to pass into this function. I do not have much experience with COM. The reason we are using this HtmlHelp API instead of the System.Windows.Forms.Help definition is becasue we want to read directly from our already created .chm file. If there is a way to do this with .net controls, please let me know as well. Thanks in advance!
|
|
|
|
|
Dear, Sir and Madam
Please see the code below.
bool bCtrl = false;
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
bCtrl = e.Control;
this.Text= bCtrl.ToString();
}
private void treeView1_KeyUp(object sender, KeyEventArgs e)
{
bCtrl = e.Control;
this.Text= bCtrl.ToString();
}
private void treeView1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
if(bCtrl)
DoDragDrop(e.Item, DragDropEffects.Copy);
else
DoDragDrop(e.Item, DragDropEffects.Move);
}
While I dragging item(node) why the KeyDown event is not fire?
How to solve this problem?
Sorry for bad English.
Thank You.
|
|
|
|
|
|
It's not supposed to. If you want to detect if the CTRL key was pressed while dragging, handle the Control.QueryContinueDrag event. See the documentation for that event as well as the QueryContinueDragEventArgs in the .NET Framework SDK for more information and examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a class in my middle tier in which I hold a DataTable object, which has already been filled out with data. All I want to do is filter the DataRows based on one of the Fields in the DataRow, and return a DataTable object with the filtered Rows.
This is my code:
public DataTable FilteredData( int clientType )<br />
{<br />
string filter = "CLIENT_TYPE = " + clientType;<br />
DataRow[] foundRows = _myData.Select( filter );<br />
DataTable dt = new DataTable();<br />
foreach( DataRow row in foundRows )<br />
{<br />
dt.Rows.Add( row );<br />
}<br />
return dt;<br />
}
The problem is that when it reaches the line dt.Rows.Add( row ); I get an exception saying that "This row already belongs to another table". It doesn't matter that I will be returning a seperate DataTable, as the Rows won't be updated in the interface. Can someone please tell me how I can return my data in a DataTable object, I would rather not have to return an array of DataRows.
|
|
|
|
|
Why don't you use DataView instead of DataTable?
You won't have to duplicate the data.
With your approach, you have to clone each row as DataRow can only belong to one datatable.
|
|
|
|
|
I would recommend you don't disconnect the DataRow from its DataTable . There is a lot of other information in there, such as change information - not to mention that the column definitions are part of the DataTable (which you didn't replicated; FWIW, the easiest way to do that is DataTable.Clone , which replicates only the structure).
An array of DataRow s is still bindable, as well. An array implements IList so that you can bind it to a DataTable , ComboBox , or any other control. In this case, it's much better to bind against a DataView instantiated with the DataTable as the ctor parameter, then use the RowFilter property. This will track all changes.
If you don't need binding or change tracking and just want a simple list of DataRow s, then you'll either have to cope with the array, remove them from the old table and add them to the new table (and use a reverse for loop - changing the enumerable will throw an exception), or use Array.CopyTo (inheritted from your DataRow[] ) which will perform a deep copy (a shallow copy won't solve your problem, since it only copies a reference to the original (same) object).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for all your help. I have decided to continue with using DataTable objects as the interface between the DataLayer and the Business layer and to now use DataView objects as the interface between the BusinessLayer and the GUI.
|
|
|
|
|
I must profess my config file ignorance. I'm required to use an open source logging project. The project deposits logs into text files based on a path attribute in my application config file. I would really like to dynamically set that path, say to, the application path. Can you use functions in a config file, or do I have to just do it manually?
Thanks,
Ryan
|
|
|
|
|
If you want the application path, simply use Application.StartupPath . Don't force a user to put the path of the executable into the .config file in that very path - it's redundent, requires extra steps (always faulty), and is easy to get from code (even with native executables).
If you want simple string settings, see ConfigurationSettings.AppSettings in the .NET Framework SDK, which also includes examples.
If you want to make your own configuration section, implement IConfigurationSectionHandler , which is documented in the .NET Framework SDK as well and includes samples. There are also several articles here on CodeProject that discuss section handlers that you should search for.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey Heath,
As I stated in my orginial post, I am forced to use an open source project that requires me to use the .config file. Is there a way to use COnfigurationSettings.AppSettings in the .config file?
Thanks,
Ryan
|
|
|
|
|
What does that have to do with open source? ConfigurationSettings.AppSettings and Application.StartupPath should both be available for any project that is run against an implement of the CLI (.NET, Mono, and Portable.NET). Read about the <appSettings> section in the .NET Framework SDK.
Open source just means the source is available for anyone to use and modify according to the license agreement. What language, framework, platform, etc. is not a factor of whether or not something is called "open source". Technically, every project posted on this site that provides source code is open source.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
you only store data in the config file. There isn't any environment variable type of mapping unless the library provides it.
You probably have to set the logging directory programatically whenever the application directory changes.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Thanks Andy, thats what I needed to know. I wasn't sure if there might be some sort of environment variables.
Ryan
|
|
|
|
|
Hi!
I was wondering... Is it possible that ApplicationException (or any other Exception class for that matter) catch some errors that Exception cannot catch? ApplicationException inherits from Exception so I assume Exception would catch every errors ApplicationException would.
Thanks a lot
P.S.: btw, I haven't seen such a thing... yet
----------------------
Be proud. Be yourself.
|
|
|
|
|
Exceptions are caught in order:
try
{
}
catch (TargetException e)
{
}
catch (ApplicationException e)
{
}
catch (Exception e)
{
} If an exception was thrown and was a TargetException , then it would be caught by the first catch block. If it was any other derivative of ApplicationException (or ApplicationException itself), then the second target block would catch it. If it was any other Exception , the last line will catch it. If you don't plan on using the variables, you can drop them (just use catch (Exception) . If you don't plan on using the exception information, you can simply use catch to catch all exceptions.
If you reverse the order of the first two catch blocks, the first catch block will catch all derivatives of ApplicationException , including an ApplicationException itself. In fact, this generates a compiler error.
You should take a look at the C# Language Specification[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone has ever encountered this problem?
I called a method but it doesn't execute (btw it's executed most of the time but sometimes it's not)
Here's what I've done to test this:
I call the method normally and the first line in the method is a Trace.WriteLine instruction.
So I guess either of two things happen:
1. Trace is not working properly (which would be pretty bad)
2. My method really is not called (which I think is even worse)
but everything after the call seems normal...
I'm thinking maybe
ThreadPool.QueueUserWorkItem(new WaitCallback(SendData), DataObj);
causes the problem... but it doens't seem to get there since the Trace.WriteLine instruction mentioned above is not executed (well no text is in my log!)
----------------------
Be proud. Be yourself.
|
|
|
|
|
Tracing is not a replacement for debugging. If you really want to know if your method is being called, insert a breakpoint at the beginning of the method and click Debug->Start, or hit F5.
Trace messages are only visible if you set up trace listeners. By default, the only trace listener calls the native OutputDebugString API, which will show up in the VS.NET Output window (or any other registered debug window) when you debug your application (using the steps above). If you want to add additional trace listeners, use either the Debug.TraceListeners or Trace.TraceListeners to add instances of a TraceListener (there are some built-in, documented in the .NET Framework SDK documentation for these properties and types I'm mentioning) or the >lsystem.diagnostics/trace> configuration section (also documented in the .NET Framework SDK.
Also keep in mind that Debug method are only compiled into your assembly when the DEBUG symbol is defined at compile-time (default for Debug builds). Trace methods are only compiled into your assembly when the TRACE symbol is defined at compile-time (default for Debug and Release builds).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok thanks for the advice about trace not replacing debug
The thing is I'm trying to debug a network application (3-4 instances running locally or on computers in my LAN for now) and it's kinda hard to know what's really happening if I interrupt the normal course of execution by using debug. Do you have a suggestion other than tracing since it doesn't seem to be too good apparently.
Thanks
----------------------
Be proud. Be yourself.
|
|
|
|
|
Tracing is fine as long as you implement it correctly (but still will never give the sort of state information debugging can). As I mentioned in my previous post, make sure you actually have trace listeners installed that will work correctly. The DefaultTraceListener won't work since debugging messages are sent only to the local computer (though remote debugging services may dispatch them elsewhere - I honestedly never tried this approach). You could always write your own TraceListener derivative that sends messages using MSMQ, Web Services, or some other standard or proprietary mechanism.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've got a memory issue with an unmanaged call to GDI.
I've followed the CreateDC, releaseDC, DeleteDC step outlined in the platform SDK,these methods all return true or 1, indicating that they succeeded. However after each call to the method it consumes 3 mb of RAM and does not release the memory, the issue is that method will be called many times and builds up to about 60mb memory used.
I store a bitmap in a member variable, which i dispose of.
iWidth = nWidth;
iHeight = nHeight;
hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow());
hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,iWidth,iHeight);
image = new Bitmap(iWidth,iHeight);
GDI32.SelectObject(hdcDest,hBitmap);
GDI32.BitBlt(hdcDest,0,0,iWidth,iHeight,hdcSrc,iStartX,iStartY,SRCCOPY);
image = Image.FromHbitmap(new IntPtr(hBitmap));
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);
GDI32.DeleteDC(hdcDest);
GDI32.DeleteObject(hBitmap);
if I call GC.Collect() it clears the memory and brings it back down but this is oviously not a good idea.
Any Idea's?
|
|
|
|
|
nEgAtIvE cReEp wrote:
if I call GC.Collect() it clears the memory and brings it back down but this is oviously not a good idea
That should be your clue right there. Unmanaged resources are called "unmanaged" because they are not managed by the GC. If you call GC.Collect and it makes a difference, then unmanaged reosurces are not your problem.
The problem here is that you must dispose those images you're creating (the image ) variable. When finished (and be re-assigning image to something else), call image.Dispose() ; otherwise, the Image is not cleaned-up until the GC gets around to it or you call GC.Collect .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the reply.
I do dispose of the image variable, I just didn't include the code on the post. Although I realize my comment on the GC doesn't make sense.
I will have to investigate if any .NET objects are still hanging around, that acompany the Call to GDI) i.e the form.
thanks again
|
|
|
|