|
Yes, it can.
The reason one might not want to use a return statement, is to keep the single exit point of the method.
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I think u can use while loop instead of if statement. thats what i understood from ur code.
POOJA
|
|
|
|
|
No, that will not return control to the user. You have to exit from the event so that the user can change the input.
---
b { font-weight: normal; }
|
|
|
|
|
oh ya...... application.doevents can be used i think bt leave it.
do u have some button click event...... i mean when do u check for file present. If u have such event then in that event u can simply use if and else statement.
POOJA
|
|
|
|
|
Hello,
In your case the ShowDialog Method would be better.
You should create a YourMessageBox class, which inherits from windows.forms.
There you can implement a fileselection, okbutton and exitbutton.
If there is no file selected the okbutton is not enabled.
YourMessageBox class can then implement a Filename property (public), which is set if a File was selected.
At the Button Click Events:
private void okbutton_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Exit();
}
private void exitbutton_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Exit();
}
Code for the class who calls the messagebox:
YourMessageBox mb = new YourMessageBox();
if(mb.ShowDialog() == DialogResult.OK)
{
//mb.Filename
//Do the rest of the code
}
Hope that helps.
All the best,
Martin
|
|
|
|
|
Hello,
I have just found the custom-written event in C# needs to have at least one client registered to consume the event or else the application will crash. Why this is so? This means that if I unregister all the client methods from the event during the time the application is running and then the event occurs, it will crash. Or am I missing something?
Evidence that this is so - test bench program:
using System;
namespace EventsTest
{
public delegate void FirstEventHandler();
public delegate void SecondEventHandler();
public class EventsClass
{
public event FirstEventHandler FirstEvent;
public event SecondEventHandler SecondEvent;
private void FireOffFirstEvent()
{
FirstEvent();
}
private void FireOffSecondEvent()
{
SecondEvent();
}
public void FireOffAllEvents()
{
FireOffFirstEvent();
FireOffSecondEvent();
}
}
public class EntryClass
{
static void Main()
{
EventsClass MyEvents = new EventsClass();
string MyChoice;
do
{
Console.Write("Do you wish to register the event clients to the events? (y/n): ");
MyChoice = Console.ReadLine();
} while (MyChoice != "y" && MyChoice != "n");
switch (MyChoice)
{
case "y":
MyEvents.FirstEvent += new FirstEventHandler(FirstEventClient);
Console.WriteLine("First event registered.");
MyEvents.SecondEvent += new SecondEventHandler(SecondEventClient);
Console.WriteLine("Second event registered.");
break;
case "n":
Console.WriteLine("No events registered.");
break;
}
Console.WriteLine("Firing off all events..");
MyEvents.FireOffAllEvents();
Console.WriteLine("Press enter to continue..");
Console.ReadLine();
}
static void FirstEventClient()
{
Console.WriteLine("First event processed successfully.");
}
static void SecondEventClient()
{
Console.WriteLine("Second event processed successfully.");
}
}
}
C# source and compiled exe attached below.
Any comments on this weird behavior?
Michal
Seems like it's not possible to attach a file here, so you can download the .cs file here: http://kreslik.com/forums/viewtopic.php?t=231[^]
|
|
|
|
|
From the code, it looks like you should be getting an unhandled null reference exception in FireOffFirstEvent() when you do not register the events. This is correct.
When you create the instance of EventsClass, FirstEvent is null. If you do not register the events it is never set.
You call FireOffAllEvents()
which calls FireOffFirstEvent()
which calls FirstEvent() - which is null
One way to solve this is place a check around the delegate invocation, e.g.
private void FireOffFirstEvent() {
if (null != FirstEvent) {
FirstEvent();
}
}
Q.
|
|
|
|
|
OK. But then why there's not the same problem with not registering all the built-in events that come with, say, a windows form?
Does that mean that VisualStudio doesn't even declare these events until I use them and register them?
Michal
|
|
|
|
|
It's exactly the same with the "built-in" events.
Every example for events I know and every place in the BCL where events are invoked first checks if there's an event handler attached.
It has something to do with how the list of event listeners is managed.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
how can we create them in c# they were avilable in foxpro and ms access
┌──────────────────────────────┬─┐
│ text1 │v│
├───────┬──────────────────────┴─┴──────────┐
│ 1 │ text1 │
│ 2 │ text2 │
│ 3 │ text3 │
│ 4 │ text4 │
│ 5 │ text5 │
│ 6 │ text6 │
│ 7 │ text7 │
│ 8 │ text8 │
│ 9 │ text9 │
└───────┴───────────────────────────────────┘
thanks
|
|
|
|
|
Hello
In the search box above this forum page, search for "multicolumn combobox". You'll find some good VB articles, yet you can use them in your C# code by referencing to them.
Regards
|
|
|
|
|
thanks Nader
|
|
|
|
|
I have a DataSet and a Bound DataGrid that displays the data form my database the way I want and expect it to. All works well there. I want to be able to then use the same DataGrid to allow my users to just click on the different cells almost as if they were TextBoxes.
If that isn't possible then I am open to suggestions on how to do this. I am doing this on the web in C# using ASP.NET.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
|
I m working in image processing in C#,actually i have done all work in matlab but now now i have convert it in to C#, Can someone help me,major problem that i m facing is woking with 2d arrays
|
|
|
|
|
Well, this site has plenty of people who will help you. A general idea when posting on this site, or any site is to ASK A QUESTION. The question you should ask shouldn't be along the lines of will someone help me? Just ask the quesiton you want to know the asnwer to that is programming related and, if someone knows how to help, some will help you.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
i want to make report that will open DataBase and read two colum
as (select tblUsrs.grad from tblUsrs)
i want to display label with (exlent, very good,good) by use the tblUsrs.grad from tblUsrs
plz how can make this ........
Palestine
|
|
|
|
|
Tareq, you'll need to be more specific with the problem you're running into. Do you need help reading from the database? Do you need help with displaying the label read from the database? If you're more specific, we can better answer your question.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Dumbest. Movie. Title. Evaaar.
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
i want to send parameter from my form to crestal report file ...
Palestine
|
|
|
|
|
|
Tereq,
you can use a typed dataset to do that, for instance. This dataset can be filled in code, maybe using a Data Adaptor (along with a data connection and a SQL Select command), or manually, if you want.
The point is that you need add this dataset as a datasource to your crystal report. Therefore, you just need do drag and drop the desired field onto your report.
About showing a label associated with the fields i'm not sure. Just as a sugestion (not so good), you could create another typed dataset (or another datatable, or even, another column) to hold the string value associated with the numeric value. These stirng values could be code filled based on numeric values.(I supposed you are trying associate a numeric value (from the DB) to a sring value (excelente, very good, and so on...))
I'm sure will find something very useful if you search for a article related to crystal here in code project.
cya
|
|
|
|
|
Hi,
I've just spent days trying to learn Crystal Reports that ships with VS2005 and have found the easiest way to do anything is to create specific database tables that hold the data you wish to incorporate into your Crystal Report. Then just drag the field from the datatable view onto the Crystal Report.
Good luck and BTW. - I couldn't find *any* decent help on how to use Crystal Reports VS2005 *anywhere*. Some joker called his article "A beginners guide to CR" but it certainly isn't written for beginners.
Glen Harvy
|
|
|
|
|
sure, crystal report is harder than .rdlc reports in VS2005, but it's a lot more powerfull
|
|
|
|
|
pontonet wrote: sure, crystal report is harder than .rdlc reports in VS2005, but it's a lot more powerfull
It's a world apart , now that I think I've got the basics!
Glen Harvy
|
|
|
|
|
Hey guys
just another quicky, i want a simple way of discovering all "text boxes" on an application via interop... i figured that getting the class name would work.... mmm kinda,
some control give me:
Class: Edit
but apps wrote in .net give me:
Class: WindowsForms10.EDIT.app.0.3b95145
if there another way of asking if this hWnd IntPtr a textbox (edit) control?
Cheers
Will
|
|
|
|