|
This code, it works. Thanks!
private void BaseForm_Load(object sender, System.EventArgs e){<br />
if (!base.DesignMode){<br />
MessageBox.Show("Hello, World!");<br />
}<br />
}
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
You think this is a stupid feature? How do you think controls work when you drop them on your form? There's nothing that magically renders them at design time without running the code that's in them. You MUST run code in the controls in order to see them on the form!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Render? Did you forget InitializeComponent() method in constructor?
I just have some questions for you.
+ Do you like it shows a message like in my example at design time?
+ Do you like to get an error message and can not design your form when you only want to load the picture at runtime like this button1.Image = Image.FromFile(Constant.IMAGES_DIRECTORY_PATH + "Back.jpg"); ?
These only some simple cases. If you like them, this stupid feature is for you!
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
This is exactly why the form exposes a DesignTime property as pointed out above
|
|
|
|
|
If you code your components correctly, this isn't a problem!
Yes, I've written many of my own components, and yes, this "stupid feature" as you call it, is what made developing these components remarkably easy.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can you show me the correct way to write a component? I want to see if it is correct or not.
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
Funny! What do you think we've been trying to tell you!?
Why is it so hard to accept that when you drop a component on a form, the code in it runs at design time?!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I told you the reason why I think this feature is stupid. But you, nothing.
I just want to give you an opportunity to defend your idea. And if you cannot defend it, I will keep my idea until I find it fail.
Don't wasting my time!
I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
|
|
|
|
|
I don't have to!
Just try and develop a control without that functionality! Of course, you can't turn it off, so, you'll just have to imagine that when you drop your control on a form to test it, nothing happens! You get a nice black hole where your control should paint itself. Why? Your rendering code doesn't run until you hit F5. You try changing a couple of properties to see if the rendering code is OK or see what the affects are, and nothing happens, until you hit F5. What a pain...
It makes developing controls much easier to write and debug. If your skills can't handle that, well, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do I get a windows media player control on my webpage?
Thanks
Sean
|
|
|
|
|
|
Ok where do i begin...
well i am trying to come up with a solution to allow me to register event handlers with an event dynamically. Consider the following code
<br />
if (aEvent.Name.CompareTo("getFilesCalledEvent") == 0)<br />
{<br />
Delegate myDel =Delegate.CreateDelegate(aEvent.EventHandlerType,<br />
this, "EventCalled");<br />
aEvent.AddEventHandler(this, myDel);<br />
}<br />
As far as im concerned this should register the method EventCalled contained in the running instance of the object pointed to by (this).
When executed i get the exception "Object does not match target type", when i call the AddEventHandler Method.
As far as i can assume this is because im using remoting, see aEvent is actually an EventInfo type returned from a remote object. So im guessing the delegate im passing in is actually trying to point to a local instance. But im registering it with a remote object, so when it tries to call back to the class that holds EventCalled it does not know to go through the remoting framework? Ie The object is pointing to does not exist in the context of the remote object.
This is my best guess anyone who can help your a godsend!
|
|
|
|
|
It's easy enough to craft a Form by dragging controls onto it from the toolbox, but can the same thing be done to create a standalone Panel class? I know I can drag controls onto a Panel that's part of a Form , but I'd like to design a reusable panel independent of its parent Form .
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Add a new control to your project. Right click your project; select Add->New Item; then select User Control.
Hope this helps.
-SHaroz
|
|
|
|
|
|
I am trying to get a commercial program to copy it's text file to the clipboard.
This code activates the correct window, brings it to the foreground and processes the mouse clicks:
input.mi.dx = 950;
input.mi.dy = 300;
SetCursorPos(input.mi.dx, input.mi.dy);
SetForegroundWindow(commercialWindowHandle);
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTDOWN);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
I have verified that the above code works all the time ... but the following code sometimes works ... mosttimes doesn't !!! :
SendKeys.Send("^{a}"); // Select all text
SendKeys.Send("^{c}"); // Copy to clipboard
(It would also be nice if i could set the mouseDown and mouseUp relative to the foreground window instead of to the absolute screen but that is not my primary concern right now)
Thanks in advance for any insight.
-- modified at 19:38 Monday 20th February, 2006
|
|
|
|
|
Try SendWait instead of Send. Also, if that doesn't work, make a call to Application.DoEvents after each SendKeys.SendWait call.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
Thanks for the suggestions, Judah
I tried them all ... but none worked. Surprisingly, this DID work ... the code has been working 100% of the time so far (knock on wood):
int pauseTime = 100;
System.Threading.Thread.Sleep(pauseTime);
SendKeys.Send("^(a)");
SendKeys.Send("^(c)");
It appears that the commercial program just needed some time between the mouse simulation and the keyboard simulation. Surprise! Surprise!
|
|
|
|
|
i want read a html and to extract the attribute's value given within tag.e.g .i want to extract values of attributes name and content.plz help me ...Rizwan
|
|
|
|
|
rizwan_rashid wrote: ttribute's value given wi
There's a couple options here. If these tags are in an HTML page, you could load the html document into the WebBrowser control, then access the individual elements using the WebBrowser's Document Object Model (DOM).
Another option is to parse the thing using XML parsing. If you've got a schema, great, it will help you figure out what goes where and will provide for a more predictable document. If there's no schema available, you can always just parse it blindly and try to find the attributes of all meta tags. Look into System.XML for that.
Finally, the last option would be to use regular expressions. For that, look into the System.Text.RegularExpressions namespace.
|
|
|
|
|
Hi,
I am new in C#. I want to clear the text in the textbox when I click on it. Is there any way to do that like Onclick event in VB?
Thank you for your answer.
|
|
|
|
|
Should be very similar to VB.
Drag a text box control onto the form. Right click the text box and hit properties. At the top of the properties window you will see a button that looks like a lighting bolt. Click on that and you will see all the events associated with that control. Double click on the label that says 'Click'.
If, for whatever reason you are not using visual studio add this code:
<br />
this.textBox1.Click += new System.EventHandler(this.textBox1_Click);<br />
<br />
private void textBox1_Click(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
In either case insert this code into the textBox_Click method.
textBox1.Clear();
But of course use the name you have assigned the text box for the code.
Hope that helps
|
|
|
|
|
THank you so much. It works!
|
|
|
|
|
hi Sean89!
if you're customizing or inheriting a textbox, you can override the OnClick Event handler of it.
like this:
public class MyTextBox : TextBox
{
public MyTextBox()
{
}
protected override OnClick(EventArgs e)
{
this.Clear();
}
}
hope that helps!
microsoc
|
|
|
|
|