|
if i don't want to print any number (1 or 2), i want to go to deadlock "obj1" immediately, so how can i fix my code?
|
|
|
|
|
I have a MDI winform program, I create a child WinForm frmChild;
In this frmChild, I have a button Add to do some operation, after the operation is done, I want to destroy the frmChild form.
How can I do this?
OnBtnAdd()
{
do_operation();
}
|
|
|
|
|
Did you try Close()?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Dear all,
I set a label auto size is false, and dock is full in a pane, because label.text is dynamic words, it can't see some label text if we put much words! I want to make label font auto change when text is much!
How to do it?
Thanks
|
|
|
|
|
I guess you'd have to check the number of characters in the text, and change the associated font size property for the label. You could do this when the layout phase has finished. Be aware, though, that if the font size goes too small, your users won't be able to read the text.
|
|
|
|
|
Thanks for your answer
Do u know how to code it define a fit font size for current the number of characters in the text?
|
|
|
|
|
That's really going to be up to you. I don't know how big your label is - there's a reason for this knowledge, as you are going to have to use that as a basis for your scaling factor - it's going to be a bit trial and error for you.
|
|
|
|
|
In my Win32 days I did this using DrawText()[^] with DT_CALCRECT . Sorry, but I don't know of a .NET equivalent.
/ravi
|
|
|
|
|
Whenever u select the first dropdown button(india),
when automatically updated to next dropdown(andhra pradesh)........like this scenario
can u plz anybody give me the code........
|
|
|
|
|
|
R@vuri wrote: can u plz anybody give me the code........
The dreaded text speech asking for code
Look here[^] before posting questions.
In addition, please don't use text speech, write full sentences.
thanks.
V.
|
|
|
|
|
Hi,
If u select the check box like(gmail,yahoo),all the check boxes selected..........
can u anybody plz give me the code
R@vuri
|
|
|
|
|
try this javascript function
function SelectAll(cntrl,grd,indCat)
{
var grdComp = document.getElementById(grd);
if(indCat == '1')
{
for(i=1;i<=grdComp.getElementsByTagName('input').length-1;i++)
{
grdComp.getElementsByTagName('input')[i].checked = cntrl.checked;
}
}
else if(indCat == '2')
{
var chkInd = true;
for(i=1;i<=grdComp.getElementsByTagName('input').length-1;i++)
{
if(grdComp.getElementsByTagName('input')[i].checked == false)
{
chkInd = false;
}
}
grdComp.getElementsByTagName('input')[0].checked = chkInd;
}
}
hope this helps
with regards
Karthik Harve
|
|
|
|
|
|
The simplest solution is to run a loop through the checkboxes and then check / uncheck them.
There are other more complex solutions like using LINQ etc.
Try one that suites you best.
|
|
|
|
|
I had a MDI WinForm Program, when click from a menu item, I new a new child WinForm(this child WinForm designed in the designer), but this new child WinForm is not maximumed even I set the childForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
Could you show me how to do this? Thanks in advance!
|
|
|
|
|
if you want this child to be open as a separate maximized form then try this below code..
CHildForm frm = new CHildForm();
frm.WindowState=FormWindowState.Maximized;
frm.ShowDialog();
[or]
if you want this child to be open as maximized within the MDI parent, then try this..
CHildForm frm = new CHildForm();
frm.WindowState=FormWindowState.Maximized;
frm.Show();
hope this hepls.
with regards
Karthik Harve
|
|
|
|
|
Actually, I am doing this, this doesn't work. Maybe some property I've set wrong?
|
|
|
|
|
Gentleman,
I am using a list box to list some string information gathered from an MSSQL database. I noticed that if I select the box and should "miss" the string line (selecting empty space), a null exception is thrown. The problem is that it also closes the application. I have tried several different ways to escape this by showing the exception (try, catch) and trying to return to the application, but they have all failed. Ideas?
Thank You, Pat
|
|
|
|
|
You say that an exception causes your program to close. This is normal.
You must show what code you're using in the selection event handler to get any real help with this.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
A lot of Controls, including System.Windows.Forms.ListBox will fire unexpected events, forcing you to code defensively. As an example, a SelectionChanged event (or whatever it is called) may be fired when an item gets deselected, which you can check by looking for a negative SelectedIndex, or a SelectedItem being null. If you don't, you're bound to run into trouble.
Also don't be surprised it you use OwnerDraw mode and get MeasureItem/DrawItem events with an index of -1.
IMO all these can be avoided by proper testing before acting; and all can be caught with proper try-catch constructs.
Finally, without actual code, we can't provide more specific help. I have noticed you seldom provide code when in fact you should.
|
|
|
|
|
Thank you Luc (nice of you to reply to me again) and to all of you in fact for your excellent replies. All are good advice and I intent to use it all. Re: The Issue; most of the time, I usually find myself embarrassed when I finally solve some of these things. I employed the following simple one line of code in the SelectedIndexChanged event to resolve the issue:
private void listBoxXxx_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBoxXxx.Items.Count < 1)
{
string msg = "There are no Items in the list to select from. ";
MessageBox.Show(msg, "Required Information Missing", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (listBoxXxx.SelectedIndex != -1)
{
labelXxx.Text = listBoxXxx.SelectedItem.ToString();
}
}
To my friend and mentor Luc...actually, I looked up my history and I usually do supply the code when the issue is code failure but not when (I don't know how) which is sometimes the case. In this case, I should have supplied the following, but it was so basic I could not understand the possible link, so please accept my apology.
frmMain m = new frmMain(fname, title, firm, firmId, permission, theDate, userId, chal, CONNSTR);
this.Hide();
m.ShowDialog();
}
}
catch (SqlException Sqlex)
{
MessageBox.Show("Error: " + Sqlex, "SQL Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Most important...thank you all for your interest and expertise. Luc, your answer was closest to what I used and I am marking it as the correct solution. Best Regards, Pat
|
|
|
|
|
My guess is you're doing SelectedItem.something in the event handler. If you select nothing, SelectedItem will be null, and SelectedIndex will be -1. You should always check for these conditions in any event handler that uses one of these properties; I typically put a guard at the top, since you usually don't want to do anything in that case:
void ListSelectionChanged(object sender, EventArgs e){
ListControl list = (ListControl)sender;
if(list.SelectedIndex < 0) return;
...
}
|
|
|
|
|
Has anyone ever developed a com class to allow data to be extracted from MT4 platform? I have developed a TCP/IP wrapper class which works great, but MT4 does not seem to allow multiple TCP/IP sessions!?
I see this (http://www.mql5.com/en/articles/249[^]) article online, has anyone have any experience with this? Its supposed to work for MT4 as well.
Mike
|
|
|
|
|
Hello , I'm learning English. My English is low.
My question is : I have two keyboards in my pc. I was studing this article from Using Raw Input from C# to handle multiple keyboards[^] from Emma Burrows. I understan the article.
Now I can identify any keyboard, for example : Keyboard 1 is A, Keyboard 2 is B.
In my aplicacion that I'm doing in C#, I use two keyboards, A and B, if I press any key from keyboard A, my program say : Hello Word. If I press any key from Keyboard B, my program say : Bye ! World! . This is in my program.
My question is : I want isolate keyboard B, the keyboard B must exist only for my program, for example, if I want write in notepad when my aplication is running with keyboard B, this must be imposible because I want use keyboard A and B ONLY in my program , but I want write with keyboard A in notepad, I must can it. I must write in others programs only with keyboard A.
The keyboard B must not exist for other aplications. Only must exist the Keyboard A for the aplications , but my program work with keyboard A and B.
This is because I'm using a barcode gun, for windows it is a keyboard. If you are writing a e-mail and I use the barcode gun, you can see numbers in you email when you are writing. I want avoid that.
If you are writing with keyboard A a e-mail and I use the barcode gun or keyboard B, Windows must ignore the codebar gun.
Ok, I hope do you understand me.
|
|
|
|