|
Hello,
I am not quite sure about this behavior. This should not happen. It might be some part of the coding
that is leading to the change in focus.
You can try this code and check.
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
this.treeView1.Nodes.Add("Node0", "Node0");<br />
this.treeView1.Nodes[0].Nodes.Add("Node1", "Node1");<br />
this.treeView1.Nodes[0].Nodes[0].Nodes.Add("Node2", "Node2");<br />
<br />
}<br />
<br />
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)<br />
{<br />
MessageBox.Show(e.Node.Name);<br />
}
I hope this will help.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
thank you...my mistake was
MessageBox.Show(treeView1.SelectedNode.Name);
This was creating Problem...
*** Why EXPERTS behave like a fool ***
|
|
|
|
|
Hi,
When i export the CR Xi report to PDf in programmatically, it give parameter missing error,
Pls help me if you know the solution
thanks in advance
"FAKEER"
|
|
|
|
|
Here[^] - google for the company the produces the API you're using, and ask them. This is not a C# question, it's a question about a library you're using.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Interesting article you've written there. I can imagine the frustration you must have felt when you decided to write it.
I think it's sad that the situation warrants an article like this.
Cheers,
Vikram.
Zeppelin's law: In any Soapbox discussion involving Stan Shannon, the probability of the term "leftist" or "Marxist" appearing approaches 1 monotonically.
Harris' addendum: I think you meant "monotonously".
Martin's second addendum: Jeffersonian... I think that should at least get a mention.
|
|
|
|
|
I agree. But, I didn't mean it as a cheap shot, the situation DOES warrant it, and I hope it helps.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I wrote a piece of code to monitor keyword activities (just for fun and testing this api func) I want to know what is wrong? sometime I get this error:
{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}
Stack trace:
" at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run()\r\n at hook.Program.Main() in C:\\Documents and Settings\\Nazila\\My Documents\\Visual Studio 2005\\Projects\\hook\\hook\\Program.cs:line 19"
my code is :
public class KeyPosition<br />
{<br />
static public Int16 WM_KEYDOWN = 0x0100;<br />
static public Int16 WM_KEYUP = 0x0101;<br />
static public Int16 WM_SYSKEYDOWN = 0x0104;<br />
static public Int16 WM_SYSKEYUP = 0x0105;<br />
}<br />
<br />
delegate int HookProc(int code, IntPtr wParam, ref keyboardHookStruct lParam);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]<br />
static extern IntPtr SetWindowsHookEx(HookType hook, HookProc callback, IntPtr hMod, uint dwThreadId);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)]<br />
public static extern bool UnhookWindowsHookEx(int idHook);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]<br />
static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, ref keyboardHookStruct lParam);<br />
<br />
[DllImport("kernel32.dll")]<br />
static extern IntPtr LoadLibrary(string lpFileName);<br />
<br />
public enum HookType : int<br />
{<br />
WH_JOURNALRECORD = 0,<br />
WH_JOURNALPLAYBACK = 1,<br />
WH_KEYBOARD = 2,<br />
WH_GETMESSAGE = 3,<br />
WH_CALLWNDPROC = 4,<br />
WH_CBT = 5,<br />
WH_SYSMSGFILTER = 6,<br />
WH_MOUSE = 7,<br />
WH_HARDWARE = 8,<br />
WH_DEBUG = 9,<br />
WH_SHELL = 10,<br />
WH_FOREGROUNDIDLE = 11,<br />
WH_CALLWNDPROCRET = 12,<br />
WH_KEYBOARD_LL = 13,<br />
WH_MOUSE_LL = 14<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto,Pack=1)]<br />
public struct keyboardHookStruct<br />
{<br />
public int vkCode;<br />
public int scanCode;<br />
public int flags;<br />
public int time;<br />
public int dwExtraInfo;<br />
}<br />
<br />
static IntPtr hooked = IntPtr.Zero;<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
this.Hide();<br />
IntPtr hInstance = LoadLibrary("User32");<br />
hooked = SetWindowsHookEx(HookType.WH_KEYBOARD_LL,Form1.Hook, hInstance, 0);<br />
<br />
}<br />
static string hookedstr;<br />
static string hookedDownStr;<br />
<br />
public static int Hook(int code, IntPtr wParam, ref keyboardHookStruct lParam)<br />
{<br />
<br />
if (code < 0)<br />
{<br />
return CallNextHookEx(hooked, code, wParam, ref lParam);<br />
}<br />
if ((int)wParam == KeyPosition.WM_KEYDOWN)<br />
{<br />
hookedstr += "[D]";<br />
hookedDownStr += ((Keys)lParam.vkCode).ToString() + " ";<br />
}<br />
hookedstr += ((Keys)lParam.vkCode).ToString() + " ";<br />
return CallNextHookEx(hooked, code, wParam, ref lParam);<br />
}<br />
<br />
return 0;<br />
}
|
|
|
|
|
I have a datagridview to display one datasource. I catch record to modify and then display on screen
|
|
|
|
|
So
do u want to bind to gridview?
set the datsource and datamember to gridview.
that's all
thanks
|
|
|
|
|
Please read this[^].
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
In my application I am able to load plugins, i.e. use reflection look in an assembly for classes implementing a given interface and instantiate them.
I would like these plugins to run with restricted right.
Like they are not able to access the file system, etc....
How could I do that?
Also, from some prelimiary reading it seems I will have to run thess plugin in different AppDomain, but these plugin need to create some WPF.Controls I'm adding to my main form's visual tree hierachy.
Is it possible to do that? I mean add in the UITree a WPF.Control which is from a different AppDomain?
(I foresee a dispatcher problem)
Any tip? (or maybe I don't need to run my plugin in a different AppDomain after all?)
|
|
|
|
|
I have used crystal reports in C# .net in my application
when I run my application on my client PC where Visual Studio 2005 IDE is not installed, the forms having crystal report do not display.
The .net framework 2.0 has already been installed on the coimputers but I was wondering if there is any other also required to display crystal reports.
Sadaf
|
|
|
|
|
Ok can can
Please check ur client pc for MS report viewer is installed?
thanks
|
|
|
|
|
How come this doesn't work when you click the button?
foreach (Control txt in this.Controls)
{
if (txt.GetType() == typeof(System.Windows.Forms.TextBox))
{
txt.Text = "";
}
}
I had another one that using a for statement instead of foreach and it won't work either.. here it is:
for (int i = 0; i < this.Controls.Count; i++)
{
if (this.Controls[i] is TextBox)
{
this.Controls[i].Text = "";
}
}
|
|
|
|
|
Try casting the control to a textbox then reference its properties.
Just because we can; does not mean we should.
|
|
|
|
|
Uhm what do you mean by that?
|
|
|
|
|
Here's an example. You need to "cast" it to the type of control you expect it to be and not the control object it self. Simply comparing its types wont give you access to the, in this case a TextBox, properties like .Text and so forth.
foreach (Control txt in this.Controls)
{
if (txt.GetType() == typeof(System.Windows.Forms.TextBox))
{
TextBox txtbx = (TextBox)txt;
txtbx.Text = "";
}
}
Just because we can; does not mean we should.
|
|
|
|
|
Ok I see, but it still isn't working.. its weird because I have this:
for (int i = 0; i < this.Controls.Count; i++)
{
if (this.Controls[i] is TextBox)
{
this.Controls[i].Text = "";
}
}
under a listbox selection change committed and it works every time!
|
|
|
|
|
Jacob Dixon wrote: for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i] is TextBox) { this.Controls[i].Text = ""; } }
Instead of 'is', use 'as'.
TextBox tb = Controls[i] as TextBox;
if (tb != null)
{
// whatever
}
If the property you use exists on the Control class, then your code will work, if you try to use properties that are specific to the class you failed to cast to, it will not.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So if your talking about this it still doesn't work:
private void button10_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.Controls.Count; i++)
{
TextBox tb = Controls[i] as TextBox;
if (tb != null)
{
tb.Text = "";
}
}
Phone2Listbox.Items.Clear();
phoneListbox.Items.Clear();
AuthPhone1Listbox.Items.Clear();
AuthPhone2Listbox.Items.Clear();
AuthPhone3Listbox.Items.Clear();
MedAllergiesListbox.Items.Clear();
MedPhoneListbox.Items.Clear();
EmergPhoneListbox.Items.Clear();
PaidToDateListbox.Items.Clear();
richTextBox1.Clear();
othercomments.Clear();
}
Is that what you were talking about?
|
|
|
|
|
Yes, if that doesn't work, then this code just plain is not running, or something else is strange on your form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Both examples work under a button click event.
<br />
foreach (Control txt in this.Controls)<br />
{<br />
if (txt.GetType() == typeof(System.Windows.Forms.TextBox))<br />
{<br />
TextBox txtbx = (TextBox)txt;<br />
txtbx.Text = "";<br />
}<br />
} <br />
<br />
<br />
for (int i = 0; i < this.Controls.Count; i++)<br />
{<br />
if (this.Controls[i] is TextBox)<br />
{<br />
this.Controls[i].Text = "";<br />
}<br />
}
Difference between the two is that the first refers to a Control object. So you need to cast it to the TextBox control to gain access to the TextBox property?. Otherwise your setting the text of the control. Check it out in the debugger! In the second you reference the actual object and this exposes the objects, in this case a TextBox, .Text property.
Hope this helps.
Just because we can; does not mean we should.
|
|
|
|
|
Also, 'it won't work' is not really a question. What does it do ? Does it compile ? What happens when you step through it in the debugger ? I suspect your real problem is not casting, as Control has a Text property, but you've not really done enough work to tell us what is going on, or to try and work out what's really happening.
My best guess is that this code is not running at all.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am using the same thing on the listbox selection committed and it works..
I set some break points to see if it is doing anything.. I am not getting any errors at all.
I have about twenty textboxes and I see that it is clearing one text box. But it is not clearing any of the other ones.
|
|
|
|
|
actually it is clearing that one textbox and every item in a ListBox???
|
|
|
|