|
Either use a RichTextBox and have some complicated code to catch it when the user clicks an embedded hyperlink, or add a label for each word to a panel and hook up their click-events.
Bastard Programmer from Hell
|
|
|
|
|
Thanks for advice, Eddy, I'm not a programmer yet, just a student getting stuck with this problem
|
|
|
|
|
Aight, then we'll take the easy route. Can you create a panel dynamically and add it to a form? Would be something like this;
public Form1: Form
{
Panel myPanel;
public Form1()
{
InitializeComponent();
myPanel = new Panel();
myPanel.Dock = DockStyle.Fill;
Controls.Add(myPanel);
}
}
After that you'd add a Label control to the panel for each token in your file, in a similar way. If you set their Dock property to align to the left, they'd line up nicely within the panel. Once you got that, it'd be easy to hook up a method that gets executed when someone clicks on a label
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I have a crystal report.
I have list of items which gets printed in the detail section of the report.
I have one field which should come at the end of detail section, regardless of number of items.
currently that field is coming after first item.
I want something like below
===============================
DETAIL SECTION:
ITEM1
ITEM2
ITEM3
(Here I want my field, which should come only once)
===================================
Thanks in advance
|
|
|
|
|
Hi,
Why the App.Config is usually copied in the application folder in Program Files? any technical reason?
Is it advisable to move it to the AppData folder?
|
|
|
|
|
jrahma wrote: Why the App.Config is usually copied in the application folder in Program Files? any technical reason?
Is it advisable to move it to the AppData folder?
A logical reason; it's a configuration at application level. The documentation on the <a href="http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx">SpecialFolder</a>[<a href="http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx" target="_blank" title="New Window">^</a>] enum contains explanation on what the different folders are used for.
Bastard Programmer from Hell
|
|
|
|
|
I never use App.Config; I always roll my own in AppData.
|
|
|
|
|
you should not move application configuration file to AppData.
Reason : App.config file is configuration for the application as its name suggest but at the time of deployment. You should not touch this file once the application is installed.
The reason why this file is copied to the installation folder is same as that of all the exes and dlls that you deploy. which are not editable or undergo any changes unless a new version is installed.
Installation folder : is a base image of your application
App Data Folder : is deployment/user specific and can be altered at any time.
Generally, administrator has a rights to change the installation folder. A normal user can not change any files within it. Problem arises when you give control to user over this installation directory. Think if this config file is tempered by the user. Config files are automatically loaded by the application and hence result in application crash where as, appData folder can be loaded and validated by the code.
I am not sure why you want to do this but, I am guessing you want some of the settings to be altered at the run time. If that is the case then there is option for doing this in the visual studio. There are two types of the settings Application & User, user use setting for this case
Hope this helps
Happy Coding
|
|
|
|
|
G'day people,
I was wondering if I could get a point in the right direction on how to squash a bug. The app I am writing is basically a control panel type thing, and it brings up notification boxes if something needs to be actioned.
On certain computers, if the user clicks "Snooze All" in the notification box, the application crashes with a StackOverflowException. All the "Snooze All" button is doing is manipulating DataTables and closing the notification box. I was originally wondering if it was a DLL issue, but I can't see why it would happen whilst running - not opening or closing any forms at all!
The error information is listed below.
Problem Event Name: CLR20r3
Problem Signature 01: afns gui 3.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4fe2c742
Problem Signature 04: System.Windows.Forms
Problem Signature 05: 4.0.0.0
Problem Signature 06: 4da3cf4e
Problem Signature 07: 3e23
Problem Signature 08: 0
Problem Signature 09: System.StackOverflowException
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 3081
Additional Information 1: c51c
Additional Information 2: c51c01e8afa2e7706a621e0a166b392d
Additional Information 3: a841
Additional Information 4: a841e87d6b8fde0994c2a1134b39ab43
|
|
|
|
|
Without knowing more about exactly what is happening, you and I are in the same boat - it could be anything.
I would start by looking at the computers: is there anything specific to the computers it crashes on, that is not applicable to those it doesn't?
Does it happen every time? If not, when does it happen? Occasionally? Often? Very rarely? To a particular user? OS? Network segment?
Basically, you need more info. If you can get it to happen reliably, then insert logging code to try to track the path it is taking, and look for oddities in the log.
I know all this is basic stuff, and I'm probably teaching my Granny to suck eggs, but with the information so far, all I can suggest is generalities.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Basically in one room the office is shared by 8 computers. On 7/8 computers the application crashes when the snooze button is hit. This doesn't write anything back to the SQL Server, only to local DataTables.
Only one of them works correctly, all are up to date with Windows Updates.
It appears to be computer related, as when I use my local user account (I haven't tried my domain administrator account) it carries the same error. I use the same login on my Developer PC (I know, not a good test) and it works fine.
I have a rough idea of where it fails, but I have no experience with StackOverflowExceptions, so where do I go from there?
|
|
|
|
|
If you can't use visual studio I would wrap the method call in your button click with a try { }catch (StackOverflowException e){\\log the error message and stacktrace } (if any try catch blocks are inside the method calls log there also)
If you can use visual studios to debug and replicate the exception then go to the menu "debug>exceptions" and in the window that comes up expand "Common Language Runtime Exceptions" and then expand "System" and find StackOverflowException and then check the check box under "thrown". This will take you right to the line throwing the exception when using the debugger. Before you stop the debugger you can look at your locals window to see current values of any variables.
Hope that helps...
|
|
|
|
|
If it is that easy to duplicate, then you need to know what is using the stack. Add logging code which just adds to a DB or a file saying which method has been entered - start with the ones directly called by the snooze button. You are looking for a repeating pattern: MethodA calls MethodB calls Method A indirectly, or similar. That is the most common way to get stack overflow - recursive calls without a termination check. (There are other ways, by they are a lot harder to organise).
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Why don't you look at (and/or show us) the relevant code, starting at the button's Click handler that starts the trouble?
The most popular way to create a StackOverflowException is by having a property call itself, i.e. doing something like:
private int counter;
public int Counter {
get {
if (some_error_condition) MessageBox.Show("Can't comply, however the counter's value equals "+Counter);
return counter;
}
The mistake here is the upper-case Counter inside the Show method.
|
|
|
|
|
It was PEBCAK. Somehow I ended up with this.Close in the FormClosing event - And for some reason even stranger, it worked on some computers and not others!
|
|
|
|
|
OK, I never had that one before, but it basically is the same (although one might hope Windows would include a safeguard against that).
The difference amongst systems might be due to timing differences (they don't play by the book exactly when the process is exiting anyway); or just perhaps some Service Pack just added a safeguard!
If you ever find out, please let us know.
|
|
|
|
|
Hi guys!
I'm dealing with a problem I can't find a solution for. What I'm trying to do is this:
I have a Model which should contain a generic method (generic input and return value).
And furthermore these Models should be merged into a List.
And here it gets complicated and I end up in a dead end.
Here's the code which hopefully makes it more clear:
class MainClass
{
public static void Main (string[] args)
{
List<ContainerBase> containers = new List<ContainerBase>();
containers.Add(new ContainerA());
containers.Add(new ContainerB());
}
}
abstract class ContainerBase
{
public string Name {
get;
set;
}
public abstract TResult Calculate<TResult, TInput>(params TInput[] input);
}
class ContainerA : ContainerBase
{
#region implemented abstract members of Generics.ContainerBase
public override TResult Calculate<TResult, TInput> (params TInput[] input)
{
int[] ints = input as int[];
double result = 0;
return result;
return result as TResult;
}
#endregion
}
class ContainerB : ContainerBase
{
#region implemented abstract members of Generics.ContainerBase
public override TResult Calculate<TResult, TInput> (params TInput[] input)
{
throw new System.NotImplementedException ();
}
#endregion
}
This is needed because I want to be able to combine different algorithms (presented by the Model), e.g. Algo 1: combine 3 integers, Algo 2: divide two integers, Algo 3: get the sort via Drag&Drop (in MVVM - hence the unified approach).
An Alternative would be to store a whole Metod in a Property in the Model, but it needs to be generic as well. And I have no idea how to do that either.
Help would be appreciated!
|
|
|
|
|
Try
return (TResult)result;
|
|
|
|
|
won't work without type limitations, you can't convert just anything to double.
And I'm afraid the whole thing cannot be done in C#.
|
|
|
|
|
Yeah, I've just looked at his sample and noticed that he declared his value as a double. Too busy looking at the comments that sat "this doesn't work".
|
|
|
|
|
Thanks for the hint but no, this doesn't solve my problem:
public override TResult Calculate<TResult, TInput> (params TInput[] input)
{
int[] ints = input as int[];
double result = 0;
foreach (int item in ints) {
result += item;
}
return (TResult)result;
}
|
|
|
|
|
I'm not a generics specialist, however IMO what you want can't be handled by C# (or any other .NET language) at the moment. IIRC what you want falls under covariance and contravariance and its support is quite limited, see e.g. here[^].
The easiest statement on the subject is this:
List<TextBox> textboxes=new List<TextBox>();
List<Control> controls=textboxes;
will not be acceptable: even though a TextBox is a special Control, a list of them can't be "generalized". Same for method return values.
|
|
|
|
|
As an alternative, is there a chance of storing different kind of functions in a property?
Something like Func<int,int> and Func<double,double,double>?
Guess it's the same problem,but better asking before throwing the idea over board.
Do you have an approach on how this can be achieved? Something that didn't come into my mind?
Thank you!
|
|
|
|
|
This works for me... not sure if casting to object will cause you any issues or not.
public TResult Calculate<TResult, TInput>(params TInput[] input)
{
int[] ints = input as int[];
double result = 0;
byte test = 4;
result = test << 2;
return (TResult)(object)result;
}
|
|
|
|
|
Your Calculate method is seriously flawed. You want to use a generic parameter and return type but then fix the types inside the method implementation to int and double!
You can use type constraints to ensure that any properties/methods that you need (for conversion or whatever) are supported by the types specified.
|
|
|
|