|
hi,
Here i have a form with a button control.I am trying to remove button on keydown event.
"Keys" enumeration will help you do find the possiblity of other key's. Here i am check only delete key.
private void button1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.Delete)
this.Controls.Remove(button1);
}
this is a sample lead to achive your task. remaining is upto yop to develop
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
It is OK with a button control. But for a Label there is no key realted events defined. So, how can we handle keydown event??
CNU
|
|
|
|
|
Upto my leval best it won't recognize keypress/keydown/keyup . I think so other guru can help you out.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Exactly !! I too think the same.
Can we have a button control without border...means it looks like a label ??
I tried with FlatStyle property but invain.
CNU
|
|
|
|
|
hi,
override th paint event
And check for this.
private void button1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics
}
this property is very flexible and self explanatory
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I have done like this and it works well :
<br />
private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
System.Windows.Forms.Button btnMsg = (Button)sender;<br />
if(btnMsg == null) return;<br />
Rectangle borderRectangle = btnMsg.ClientRectangle;<br />
ControlPaint.DrawBorder(e.Graphics, borderRectangle, this.pnlHost.BackColor, System.Windows.Forms.ButtonBorderStyle.Solid); <br />
}<br />
Thanks a lot Sreejith !!
Cheers
CNU
|
|
|
|
|
hi,
your welcome.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
You could write your own class that inherits from Control giving you access to the KeyDown , KeyPress , and KeyUp events or you could simply override the WndProc , watch for the appropriate windows messages and act accordingly.
- Nick Parker My Blog | My Articles
|
|
|
|
|
HI~
I have written an application using C#
There are some dlls. After a few day, I have updated some of the dlls(not in the same project of the orginial application). After I copy the new dll to the application directory and run it, runtime error occured. I know it is the dll version problem. So, can we ignore the version of the dll so that the application can be run without the runtime error? Or there is any other solution to solve the problem?
Thanks
|
|
|
|
|
hi,
try to check your AssemblyInfo.cs and make sure the version info.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Is this statement specify the assemblyVersion?
[assembly: AssemblyVersion("1.0.*")]
Can I change this to
[assembly: AssemblyVersion("1.0.1000.10000")]
?
|
|
|
|
|
Goahead
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Did you register your assemblies (dll) in C:\WINNT\assembly folder (for WIN 2K)??
If yes, you have to again regiter the dll files in the assembly, every time you change them.
CNU
|
|
|
|
|
I am writing private assembly.
The dll is just for the application use.
In fact, can the application run regardless the version of the dll?
|
|
|
|
|
Yes...it is very much possible. As far as my knowledge goes, the version comes into picture only when you register the dll in assembly (correct me if I'm wrong).
It seems there could be some other problem. Why don't you put the error message here (that comes in your output window) ?? Or put a try catch block where your refer the dll's methods and print the exception...
Cheers
CNU
|
|
|
|
|
ting668 wrote:
So, can we ignore the version of the dll so that the application can be run without the runtime error?
You can try, but something is bound to break, if you break the interface. I suggest you create some interfaces and use them rather than the implementation classes. This will ensure you or someone dont go and break it.
top secret xacc-ide 0.0.1
|
|
|
|
|
There are two ways that you can deal with the versioning issue.
The first is to manually manage your version numbers. This is done via the AssemblyInfo.cs file. When the version value is 1.0.* the * tells the compiler to increment with each build. Making it fixed: 2.5.0.0 for example, makes it a fixed version number. The problem is that a developer can make a breaking change and not reflect it since they forgot to change version number.
The second approach is to use reflection to load the assembly. Doing something similar to this: (untested code written off the top of my head)
string ObjectName = Path.Combine(dllPath, dllName);
Assembly container = Assembly.LoadFile(ObjectName);
Type object = container.GetType(objectNamespace);
object.InvokeMember(methodName, blah blah blah)
You can load the dll regardless of version. But you are now doing it all late binding which is TERRIBLY slow. I highly recommend you not consider doing this method.
This signature left intentionally blank
|
|
|
|
|
Thanks~
I try it. However, the third statement
Type object = container.GetType(objectNamespace);
throw exception.
|
|
|
|
|
Hi,
I have developed 2 apps, AppA and AppB.
AppA is a TCP Client
AppB is a TCP Server
When AppB receives a msg from AppA, it will update the view. If I update a TextBox, Label or ListView, it works fine. However, if I update a TreeView (add a new TreeNode), it throws an exception that asks me to use Invoke or BeginInvoke.
Why it just doesn't work on TreeView? and Why using Invoke/BeginInvoke can solve this problem?
thanks
|
|
|
|
|
I think you problem comes from a mistake in your code, maybe if you show us a litle piece of the code (the "update" process you mentioned) maybe we can help you.
I hope you understand...
|
|
|
|
|
Controls should not be modified directly from another thread. Use Control.Invoke to dispatch the function call into the UI thread.
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi,
what if somebody is updating the view from AppB(the server) directly and at the same time, AppA(the client) is asking AppB to update.
(what i meant "update the view" may just be sth like textBox1.Text = "blah" or treeView1.Nodes.Add("blah") )
Can Control.Invoke handle this case?
thanks
|
|
|
|
|
Hello friends
I create a windows forms user control and put a panel inside. Then I build a project and I get the usercontrol from the toolbox and put in a new form. But the panel does not works as waited in design time... I cannot put controls inside... I have tried with Groupbox and Tabcontrols, and doesn't works too.
What I can do to can add controls in design time? In runtime I know what I can use the "Controls.Add", but I wish this in design too
I thank in advance ay help
Regards
|
|
|
|
|
hi,
private void Form1_Load(object sender, System.EventArgs e)
{
//sample user control
UserControl1 sr=new UserControl1();
//adding user control to your main form
this.Controls.Add(sr);
//creating one button
Button btn=new Button();
//changing back color
btn.BackColor=Color.Red;
sr.Controls[0].Controls.Add(btn);
}
Here you have a form with user control. If you want to add controls inside the user control which contain some groupbox or panel.Then you can refer the control (group or panel ) using there index.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thank you sreejith
But your sample code work in runtime only...
Imagine:
1) If you drag a Panel from toolbox to your form (in design), you can add other controls to this panels, simply dragging a label, button, etc, inside of this Panel.
2) But if you create a User Control with a panel inside. We will call "UserPanelControl". Now you drag this usercontrol from toolbox in the form. The Panel what is inside of our UserPanelControl is unable to receive dragged controls from VS.Net IDE (like labels, buttons) inside....
Regards
|
|
|
|