|
If you've got 50 splitcontainers on a form, your bigger problem is that you have a user interface that is horrible. For the vast majority of apps, 2 splits on a single form would probably be the maximum you would ever use at once.
|
|
|
|
|
Loop all controls on your form and match all splitContainers, for each splitContainer loop controls to find your RichTextBox.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Controls can be nested in a hierarchy. A SplitContainer typically contains two Panels, inside these Panels you could have RichTextBoxes directly, but also other Containers (Panels, GroupBoxes, SplitContainers, ...) which again contain whatever you like.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
whats the need of this much spit containers ?
|
|
|
|
|
Hello,
I have question in my mind since long time. While using exception handling, we guess which exception would come and use catch block like, catch(FileNotFoundException) or DivdeByZero etc.
Instead of this why should I not always us base class 'Exception' and let .Net Framework decide which exception has occurred? And using StackTrace property we can easily know type of exception.
Regards
|
|
|
|
|
You are free to do it any way you like in your code. However, the reason for catching specific exceptions is that you may be able to take some action that will recover from the error. For example, if you catch FileNotFoundException then you can always offer the user the opportunity to manually select a different file etc. If you just print out the stack trace and terminate you may have wasted some minutes or hours of the user's working day.
The best things in life are not things.
|
|
|
|
|
Pranit Kothari wrote: Instead of this why should I not always us base class 'Exception' and let .Net
Framework decide which exception has occurred?
To add to Richard's comment, by catching several exception types you can distinguish what has gone wrong (and depending upon the type, as Richard says , recover). If you just catch Exception you can't do this as easily, you also potentially hide things that are going wrong in your code, I've seen this:
try
{
}
catch
{
}
This is appalling discipline. If you are worried about exceptions getting to the user (and my take is that as far as possible they never should) you can add "catch all" blocks (sometimes called Top Level Exception Handling), which at the minium should inform the user that something unexpected has gone wrong and (optionally, possibly dependant on build type) log the error/stacktrace somewhere. This[^] looks like a pretty good article on this strategy, but I think the Introduction unintentionally misleads the reader: this Top Level Exception Handling is really to catch unhandled exceptions, you should really catch those you can where they are called and deal with them there.
|
|
|
|
|
I think , it is not a good practice to catch Top level exception.If you are catching the exception for logging and re-throwing , use top level .Otherwise go for specific exceptions.Dont try to catch exceptions like "divideByZeroException" , because you can fix such exceptions in the code itself.
modified on Monday, May 23, 2011 6:21 AM
|
|
|
|
|
I assure you, that Top Level Exception handling is good practise for user facing applications, it is really bad to allow the user to see a raw .net exception. At best it will give the user a load of technical detail that will get them annoyed as they won't understand it, poor dears, this will also make them think the problem is worse than it is when compared to a friendly "Something has gone wrong" popup. At worst I've seen the unhandle exception expose sensitive informtaion such as a connection string with password. Another benefit of Top-Level handlers, is logging for unexpected exceptions across the whole app, this allows the dev team to add new try/catch blocks for specific exceptions that were missed before release. This strategy quickly helps build robust systems.
What is bad practise is to locally provide a "catch all", you should try to catch only specific exception types locally.
|
|
|
|
|
|
There are two courses in one DataGridView, the name and status, the names of those who have the situation I want to show the messagebox. How do I do this?
image : http://www.imageupload.org/?d=302251731[^]
|
|
|
|
|
This got voted down, presumably for the English; however I do not think that fair so I have added a five.
If I understand your question correctly you want to check each row in the grid that contains a keyword ('var' or 'yok'), and take some action based on that word. You will need to iterate through the rows of the grid and check the value in the second column for a match. I expect you need to start with the Rows[^] collection, and proceed from there.
The best things in life are not things.
|
|
|
|
|
Hi, I have 20 TextBoxes in a form. And I have a Common KeyPress Event for all of that Textboxes.
So I try to declare the keypress event like the following manner... is it possible?
for (int Cnl = 1; Cnl < 21; Cnl++)
{
((RichTextBox)Cnl).KeyPress += new KeyPressEventHandler(this.Comn_KeyPress);
}
Thanks for the Ideas..
PARAMU
|
|
|
|
|
try something like this in your Form_Load etc:
foreach (Control ctrl in this.Controls)
{
if (ctrl is RichTextBox)
{
ctrl.KeyPress +=new KeyPressEventHandler(textChanged);
}
}
private void textChanged(object sender, KeyPressEventArgs e)
{
MessageBox.Show(string.Format("You Pressed {0}", e.KeyChar));
}
This will add the key press event handler to all RichTextBoxes on the form.
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
foreach (Control control in this.Controls)
{
TextBox textBox = control as TextBox;
if (textBox != null) textBox.KeyPress += new KeyPressEventHandler(textBox_KeyPress);
}
}
void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
TextBox textBox = sender as TextBox;
}
}
"You get that on the big jobs."
|
|
|
|
|
|
|
anyone can help me to know that how to generate fix header report with SSRS?
tbhattacharjee
|
|
|
|
|
Hello,
I get
GetAgencyListCompleted EventHandler and
GetAgencyListCompletedEventArg EventArguments delegations from a WebService to check the EventHandler result. The result property (object) of the eventhandler will bring the list of items that what I am looking for.
However, I get implicitly conversion error message in the code below. How can solve the problem?. If you know the solution, would you please show me how to do it?
Thanks.
ProntoWS.GetAgencyListCompleted += new EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>(Proxy_AgencyInfoCompleted);
void Proxy_AgencyInfoCompleted(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed)
{
Response.Write("Here");
}
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Sunday, May 22, 2011 6:26 PM
|
|
|
|
|
The important piece of information missing is the actual type of the GetAgencyListCompleted event but your error message suggests that it is not an
EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>
If it is typed non generically as
public delegate void GetAgencyListCompletedEventHandler(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed);
then the solution is to explicitly create a delegate of the correct type or let the compiler do it for you automatically.
either
ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted);
or
ProntoWS.GetAgencyListCompleted += Proxy_AgencyInfoCompleted;
If this doesn't solve your issue then please supply more information about the actual types involved.
Alan.
|
|
|
|
|
Hi Alan!
Thank you for your answer, I got rid of the implicit conversion problem with your approach but Proxy_AgencyInfoCompleted never fires up even I invoke the procedure after ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted); statement. Web service doesn't have specific asyncronous methods. Therefore I tried to call the method as follows bur Proxy_AgencyInfoCompleted didn't fire up. Do you have any idea where is the problem? Thank you very much.
ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted);
GetAgencyList = GetAgencyList = ProntoWS.GetAgencyList(Agent, User, Password, GetCityName, "TR");
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hello everyone,
I'm making a program that works on some lenovo laptops only, it makes use of Sensor.dll. I've used code below:
[DllImport("sensor.dll")]
private static extern void ShockproofGetAccelerometerData(ref APSReading accData);
I'm not sure how should I check if it exits on the system or not. I'm using lenovo laptop therefore program works fine on my system but If someone runs on different system then it should show a message "system doesn't support" or some other error message. Is it possible to check if certain dll is present in system before importing it??
Thank you
Shivam Kalra
|
|
|
|
|
Hi,
the easiest way is by putting your DLL calls (or at least the first one you are going to do) in a try block. The actual lookup of the DLL is postponed till it is actually called, and any error locating it, or its functions, is clearly turned into an exception.
You can find more about it under "Typical Exceptions" in my article here[^].
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You'll need to dynamically load the DLL at runtime so you can catch if it's not there.
Searching on "c# dynamically load unmanaged dll" yields examples, like this one...
Dynamically calling an unmanaged dll from .NET (C#)[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you guys.
I also found another way of doing it using Files.Exists method of .net.
|
|
|
|