|
Hello,
I have two webparts. They are connected - one is the provider, one the consumer. The consumer maintains a gridview. Whenever I data arrives from the provider, I call the CreateChildControls in my ConnectionConsumer method. Thus my gridview is rebuilt. But - the CreateChildControls has already been called once, at this point. I'm thinking I should go about this in a different manner. Any ideas? Thank you very much in advance.
Morten
|
|
|
|
|
Hi All,
I have created a delegate and called method in one process. And I am trying to fire event corresponding to this delegate. Programm was running without errors and exceptions. But event handing method was not firing.
could you please suggest me what I made wrong.
Thanks for great support and knowledge sharing.
--------------------------------------------------------------------------------
I have created a form with one delegate:
namespace DelegateDefenitionContainedApplication
{
public delegate void HiSrinivas(object sender, EventArgs e);
public partial class Form1 : Form
{
public static void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("You are succeeded");
}
}
}
And I have created one console application using following way:
namespace EventCaller
{
class myEventClass
{
public static event DelegateDefenitionContainedApplication.HiSrinivas ClickMe;
public void abc()
{
ClickMe += new DelegateDefenitionContainedApplication.HiSrinivas(DelegateDefenitionContainedApplication.Form1.button1_Click);
}
}
class Program
{
static void Main(string[] args)
{
try
{
myEventClass mySrinivas = new myEventClass();
mySrinivas.abc();
}
}
}
}
|
|
|
|
|
nallanch_srinivas wrote: I have created a delegate and called method in one process. And I am trying to fire event corresponding to this delegate. Programm was running without errors and exceptions. But event handing method was not firing.
From the source code you have shown, it looks like ClickMe is never called. If you add a call to ClickMe after your call to abc(), the event should fire.
Also, your code looks strange in other ways. If you want a console app that fires an event, then there is no need for Form1 to be a form at all. It could easily derive directly from Object and still work.
If you want to display a form that executes code when the button is pressed, you might want to make a Forms application, and let the IDE do a lot of the work for you.
Nathan
|
|
|
|
|
Hi all,
when building a C# project with a same output directory, the generated dlls are erased even if they don't have the same name.
For instance,
1- I build my project in Debug
2- it generates projectd.dll into C:\
3- I build my project in Release
4- it generates project.dll into C:\
5- the projectd.dll was removed from C:\
is there a way to avoid that ?
thanks for help
kort
|
|
|
|
|
Mmm, keep the debug in debug folder and vice-versa, and run a post-build batch file to copy the file to C:\ ?
|
|
|
|
|
how can i add a hyper link to a desktop application ?
I have a small notifier pops up, i want to add a link to the text written on the popup.
How can i do it c#, .net 2005, deskop app.
Thanks
|
|
|
|
|
Personally I use a link label and use System.Diagnostics.Process.Start(...) in its Click event
|
|
|
|
|
Agreed, link label is designed to look like a link, and changes the cursor to 'the hand'. So it should be fairly obvious to people that it is a link.
Then use Process.Start like Davey says.
Also note, that is you use Process.Start(WebAddress); and you have a browser window open already, it will navigate away from the page the user is viewing and towards the page you supplied, its like a browser hijack!
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
I have a WinForms application whose main form contains a custom user control (and that custom user control, in turn, contains other custom user controls, etc).
If I want the main form to handle keystrokes (such as Ctrl-S or Ctrl-X) without allowing the inner user controls to handle them first, is there any easy way I can guarantee that the main form will pick up the keystroke first (100% of the time)?
|
|
|
|
|
Hi,
you will need the Form.KeyPreview property, the Form.KeyDown event, and the
KeyEventArgs.Handled and KeyEventArgs.SuppressKeyPress properties.
|
|
|
|
|
Thanks a lot. The topic of the intricacies of handling keystrokes is probably worth an article in itself.
In my test application, I made a form with a listbox in it. The listbox contained several items, including an item that started with "S", and the application handled the Control-S functionality by displaying a messagebox.
Although the Control-S messagebox still showed up when Control-S was pressed while the listbox had focus, the application also highlighted the listbox item that started with "S" (default functionality for a listbox is to highlight based on keypresses regardless of which modifiers are also pressed). The only way to suppress this functionality was to set the KeyEventArgs.SuppressKeyPress property of the Listbox.KeyDown event (it couldn't be done in the Form.KeyDown event).
Thus, I can guarantee that my main form handles keypresses like I want it to, but I still have to hunt down the sub-controls one-by-one to make sure they don't handle keypresses when I don't want them to.
|
|
|
|
|
Is there a way I can limit the number of characters inside the PropertyGrid items. I want to allow only 5 characters. Please help
|
|
|
|
|
The only thing you can do is to validate the data *after* the user has already entered it. There is a third-party control, which does allow you to restrict what the user can enter. Check it out here[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Is there a possiblity to attach a textbox within the PropertyGrid control griditem
so this way i can set the textbox.MaximumLength =5 or something.
|
|
|
|
|
Unfortuantely, no. The data entry portion of the PropertyGrid is not accessible and there are no hooks for "when data is being entered". So you cannot restrict what is entered while it's being entered or swap out the entry control for you own control (even if it's just a TextBox).
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
Maybe I should have been more clear in my answer. There is no correct way to do this. The article you posted uses internal control names to find the proper control inside the PropertyGrid. The name "System.Windows.Forms.PropertyGridInternal.PropertyGridView+GridViewEdit" is internal to the PropertyGrid and could be changed by Microsoft. So this means your application may just stop working at some point.
Using Reflection (or in this case internal control names), you can gain access to any field/property/method/event in a .Net class. This includes all private and internal members. It is highly recommended that you don't do this, because again the creator of the class can change the inner workings at anytime (thus breaking your application).
That aside, the article's code is pretty straight forward. An attribute is created so that the developer can mark each appropriate property with a "format". Then the custom PropertyGrid looks for that format and restricts the input.
I *think* that you would need to:
1. Create an attribute that takes a maximum length and apply this attribute to your properties.
2. In CustomPropertyGrid, you can remove the m_TextBox_TextChanged method, because you won't need to use that to enforce the max length.
3. In CustomPropertyGrid, replace the parts of code where the m_TextBox_TextChanged method is assigned to and removed from the TextChanged event so that you set and reset the MaxLength property, respectivly.
Give it a shot, if you have problems then email me and I can help you work through it.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks Tom, I appreicated the time you took out to answer me. Can you enlightened more as you said that "the creator of the class can change the inner workings at anytime (thus breaking your application).". What about if lets say i run my application on .Net version 2.0 and even microsoft change the PropertyGrid control properties in .Net vesrsion 3.0 or so, will that effect ? Excuse me, as you have propbably have figured it out that I am a newbie and willing to explorer and learn more with people like you. Atleast, you have given me some thought to look after Reflection and what is that all about.
Thanks
|
|
|
|
|
Let's take an example. Assume that I'm a company providing a class/control that you purchased (e.g. Microsoft), and I have the following class that I provide you (the developer):
public class SomeClass {
private Int32 hiddenInt = 0;
public Int32 SomeProperty {
get {
return this.hiddenInt;
}
}
}
Now, I would compile this class and only provide you with the assembly. So in your code, you would only be able to see SomeProperty, because it's public. You cannot see hiddenInt, because it's private.
Also, let's assume you want to change hiddenInt (probably because changing it would result in some effect you desire, such as limiting the number of characters that can be entered into a text box). You can use Reflection to change this value, like so:
using System.Reflection;
SomeClass c = new SomeClass();
Type t = typeof(SomeClass);
FieldInfo fi = t.GetField("hiddenInt",
BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue(c, 1);
So you build your application and everything works great. But now I update my class (with bug fixes or optimizations) and I change it to:
public class SomeClass {
public Int32 SomeProperty {
get {
return 0;
}
}
}
As you can see, I removed the field and simply hard-coded the 0 in the property. Since hiddenInt was not visible to consumers of my class, I am free to change or remove it. Now if you start to use my new class, then you application will be broken. Because I no longer have the hiddenInt field.
This is a simple example, where you could simply detect that the field is no longer there and ignore the "error". But in the case of the PropertyGrid, you are enforcing user input. So your users would see a change in functionality or usability, if you were to ignore the error.
Now, in the case of the article you linked to. The code uses the "internal" name of the grid's control. This name can be changed at any time by MS.
Basically, if you start using things that are not publically visible (either public or protected in C# speak), then you can run into problems.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
who did made a program that is like Pain(simple,it only draw line,rectangular...) in Windown.if you made,you can share for me.I am making it,but it is dificult
leo
|
|
|
|
|
nta_3886 wrote: help quick
help please? and even that would be a horrible subject
nta_3886 wrote: a program that is like Pain
you know, this post IS a pain
use google
|
|
|
|
|
m@u wrote: you know, this post IS a pain
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi, there are several articles about paint programs here on CodeProject. Did you care to
look at any of them?
And if you have a specific problem, ask a clear and specific question, you will get
answers as good as your questions are.
|
|
|
|
|
1.
for Sign in
-------------
Session["original"]=user_id.Text;
FormsAuthentication.RedirectFromLoginPage(user_id.Text,false);
for sign Out
------------
FormsAuthentication.SignOut();
The problem is after sign out from user acount
if I use Internet Explorer Back Option ,
I am able to enter my previous logged in page.
How can i stop it. i.e. after logout from my account, if i use Internet Explorer Back Option ,then a message will come that your session is over. How can i do this.
|
|
|
|
|
It happens because browser loads the page from the local cache.
Try this.
On Page_Load of each page.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.ToUniversalTime());
On the Sign Out button click,
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect(FormsAuthentication.LoginUrl);
------------------------------------------------------------
"The only true wisdom is in knowing you know nothing." --Socrates
|
|
|
|