|
stevoe72 wrote:
I am getting the following NullReferenceException, erratically, from the System.Windows.Forms.TreeView component. As the stack trace shows, none of my code is *directly* involved in the exception.
Did you ever get an answer to this question you posted on CodeProject? I am having similar problems, and don't know where the error is coming from. If you figured out where to look, I'd appreciate if you'd let me know. In my application, my users are seeing this error but I can't reproduce it.
Error Messages:<br />
Object reference not set to an instance of an object.<br />
Inner Stack Trace: <br />
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)<br />
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)<br />
at System.Windows.Forms.Control.DefWndProc(Message& m)<br />
at System.Windows.Forms.Control.WmUpdateUIState(Message& m)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)<br />
at System.Windows.Forms.ContainerControl.WndProc(Message& m)<br />
at System.Windows.Forms.ParkingWindow.WndProc(Message& m)<br />
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks for any help.
Sue
|
|
|
|
|
I'm afraid that I did not have any luck establishing the cause of this error, Susan...though we do *appear* to have stopped the error occurring (for the time being).
We started to suspect that the problem was somehow related to a panel, on my form, which was initially not visible when the form was displayed. My form had two "modes" of display. When the user switched mode, I would make the panel (and it's child controls) to be visible. When they switched modes again, the panel would be made invisible. From reading articles like the following, we began to suspect that there may be problems related to having a control that was initially non-visible:
http://www.dotnet247.com/247reference/msgs/57/285567.aspx[^]
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms/2005-01/1163.html[^]
In the end, I split my form into 2 forms (one for each mode). I was able to remove the dynamic-nature of each form. All controls are visible when the form is first displayed. And the error seems to have stopped happening.
To me, it looks like the real error is occuring down in non-managed code. I don't know how to extract any further details from an error that occurs at such a level.
Hope some of this info is helpful to you. Sorry that I cannot provide a more definitive answer.
Cheers,
Stephen.
|
|
|
|
|
Actually, that may be the answer. We have several forms where we have initially non-visible panels with more controls in them. For instance if a user tries to type in a new address which is wrong, a panel becomes visible with a drop-down list of possible city/states.
Thanks very much for the links. I will look in to this, and play a little with visible/non-visible.
Susan
|
|
|
|
|
hi, I simply want to change the registry value "swapmousebuttons", I can do this. however I want to apply this setting without rebooting or logging off, much like the windows control panel does. how is this done? thanks for your help.
Stephen
|
|
|
|
|
You can use SwapMouseButton Api function
[DllImport("user32.dll")]
static extern bool SwapMouseButton(bool fSwap);
and somewhere write code like that
private void button3_Click(object sender, System.EventArgs e)
{
SwapMouseButton(true);
}
To set it back pass false value
SwapMouseButton Function[^]
MCAD
|
|
|
|
|
thanks a ton! it works perfectly.
|
|
|
|
|
I'm trying to find the path to the My Documents folder using the Environment.SpecialFolder enum, Path.GetFullPath (Environment.SpecialFolder.MyDocuments.ToString ()); but all that it's retuning to me is the full path to my executeable with "Personal" appended to the end. How do you use this enum to actually find the "My Documents" folder?
Thanks for the help.
- Aaron
|
|
|
|
|
Environment.GetFolderPath( Environment.SpecialFolder.whatever)
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
monrobot13 wrote:
(Environment.SpecialFolder.MyDocuments.ToString ());
where did you get MyDocuments.ToString();
you need to write somthing like that
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
MCAD
|
|
|
|
|
Thanks for the help.
- Aaron
|
|
|
|
|
hi, I was working on a treeview, and tried to handle the AfterLabelEdit event. Basically, what I want to do is, user need to change the text of a treenode once it's created. If the user doesnt change the text, a warning message is popup and the treenode get the focuse after user response to the warning message. My problem is, the warning message always popup twice!
Following is some of the code to handle AfterLabelEdit event,
private void tvInterface_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
{
if(e.Label != null)
{
//...
}
else
{
e.CancelEdit = true;
MessageBox.Show("Enter sth");
e.Node.BeginEdit();
}
}
Please help thanks!
|
|
|
|
|
I tried your code but i got one message!
MCAD
|
|
|
|
|
Thanks for trying. I also tried the code in the simplest case, one form with a treeview and a textbox.
The interesting thing is, when i click the textbox to trig the AfterLabelEdit event without making any change on the node label, the message box only pop up once. However, if i click somewhere else inside the treeview to trig the event, the message always pops up twice.
Really strange, I have no idea on how to block the second message box.
|
|
|
|
|
we use makefiles to build a very large application, and we are just starting with C# - we will need to use makefiles here too for the foreseable future.
I am having problems with ImageList added to a form. Inside DevStudio 2003, I add an imagelist with a few images, use some of the images in a toolbar and then save the form. When I build this simple app inside DevStudio, it runs fine.
I try to build this from the command line but when I do, it crashes on the following line:
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
Here's what the command line to build the app looks like:
csc /out:mytest.exe /t:winexe /nologo /debug+ /debug:full /res:Form1.resx AssemblyInfo.cs Form1.cs
Any ideas why it crashes when accessing the imagestream from the resources?
Thanks
Rich
remove the xxx's from the email address if you wish to write me directly.
|
|
|
|
|
i need to use a flash design in my interface in aprogram wrote by c#
and i don't know way to do that
also how can i make animation in c#
|
|
|
|
|
|
|
I want to label tick marks along XYgraph axes. The code fragment below will draw the tick marks along the x-axis. It will also draw the labels (i.e. -8.0 -7.0, -6.0 etc...) but I can't seem to get the tick marks and the numbers to line up. One problem is that when the labels float value is >= 0.0, the minus sign disappears and skews the label from the tick mark...
//Here is the code fragment
void DrawGraphXandYTicks(Graphics g)
{
Pen tickPen = new Pen(new SolidBrush(Color.BlueViolet), 1);
//Draw x-axis ticks.
float f = -8.0f;
PointF xtickPoint = new PointF(xIndent, yIndent + graphRect.Height/2);
Font labelFont = new Font("Courier",6);
SolidBrush labelBrush = new SolidBrush(Color.BlueViolet);
StringFormat strFmt = new StringFormat();
for(float fx = xtickPoint.X; fx <= graphRect.Width; fx += xtickPoint.X)
{
g.DrawLine(tickPen, fx, xtickPoint.Y - 2, fx, xtickPoint.Y + 2);
g.DrawString(f.ToString("f1"), labelFont, labelBrush, fx + 14, xtickPoint.Y + 4, strFmt);
f++;
}
Please Advise and thanks in advance
|
|
|
|
|
Use Graphics.MeasureString to find out how big your string will be, and then divide this in half to make the text centre on the tick mark.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, Im trying to make an aplication to no notity clients by remoting from one server.
I has this exception:
Type: SerializationException
Source: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
Description: System.Runtime.Serialization.FormatterServices --> System.Object GetSafeUninitializedObject(System.Type)
What do I need in security?
How can I solvethis problem?
I you need more information, jas say me.
Thank you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
is this code written in previous version of .net framework 1
MCAD
|
|
|
|
|
Sorry, I forgets to say that he is in c# 2005
This would be the problem?
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
|
Thank you so much!
I will read about.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hello gurus,
I'd like to have a code snippet that shows how to detect which treenode has been double clicked in a treeview control?
Best regards.
Fred.
There is no spoon.
|
|
|
|