|
Try this:
<br />
if (checkBox1.Checked)<br />
{<br />
MessageBox.Show("Checked");<br />
}<br />
else<br />
{<br />
MessageBox.Show("Unchecked");<br />
}<br />
|
|
|
|
|
Thank you jmac7142 for helping me troubleshoot this problem.
An tried the MessageBox as you suggested.
still no luck.
I am planning to use about five checkboxes but I can even make it work with one. May be I should the "switch" insted of the "if-else"
|
|
|
|
|
My last post worked on my machine though...
|
|
|
|
|
Guessing from your recent question about the NullReferenceException, could it be that you've messed up the controls you're working with, i.e. create one CheckBox and then test the wrong one for its Checked state?
You don't have to try switch instead of if-else, they're completely equivalent and will definitely not be the reason for your problem.
Try setting a breakpoint at where you query your CheckBox and take a look at its properties. Perhaps you can find the reason there.
Regards,
mav
|
|
|
|
|
How to solve viewing images with zoom in C# like in very common graphic editors? There you just open an image, and then view desired detail of an image (using Magnyfying glass tool). When you zoom it in, you see pixelated part of image and smaller scroll bars, so you are still able to move image.
In C#, when I try to stretch 3 megapixel image to 800%, an ugly memory problem appears. Why? I'm not resizing the image, just stretching PictureBox to see zoomed image. But this technique doesn't work. Does anybody know how to solve this? I'm lost with this task
|
|
|
|
|
Hello,
I'm trying to read data from a binary file with multiple resources that each have their own header, containing the distance to the next resource header as well as a uInt32 that needs to be read. My question is this: is it possible to read data from each resource header, keeping in mind that since this is a file type in general, and the distance to the next resource will be different for each file or resource that the user opens.
Thanks in advance.
|
|
|
|
|
Yes, of course it is possible. There wouldn't be much point of using a file format that couldn't be read, would it?
---
b { font-weight: normal; }
|
|
|
|
|
I'm aware of that, but do you have any ideas as to how?
|
|
|
|
|
You described how to read the file, what is the problem really?
---
b { font-weight: normal; }
|
|
|
|
|
What would be a good way to read the file's resource headers?
|
|
|
|
|
Hello Everybody!!!
I have one problem parsing Xml file iam using the following sheet for the xml file of mine as the code below.
<code>
<article>
<letter from = "my email address">
<subject>any subject here</subject>
<paragraph>any paragraph</paragraph>
</letter>
</article>
</code>
Now from the code above it is simple xml file but i want to know how can i retrieve the attribute value which is the email address from the attribute "From".
I know how can i access subject and paragraph but i want to know how can i access the values of attributes please any one can give me example with code please to understand how can i do such actions.
Please everybody Help me with this problem please.
Iam so appreciateful for you all.
Thanks everybody.
Mess With The Best And Die Like The Rest
-- modified at 17:05 Friday 28th October, 2005
|
|
|
|
|
Hi there,
You can use XPath quere to retrive value of attribute
Take a look on this article
Xml
<< >>
|
|
|
|
|
|
I am trying to write a function that will return the reference of a textbox control on a form. I come from a classic VB background. The questIon i have is how do i pass around a control in a variable? In VB, i could put the control in a generic Textbox variable and pass it around. But when i do this in C# nothing seems to happen. I am unable to change the textbox properties. What is the HowTo for C#? Thanks.
private void LoadCellMatrix()
{
int row;
int col;
System.Windows.Forms.TextBox textboxRef;
for(row = 1; row <= 4; ++row)
{
for(col = 1; col <= 4; ++col)
{
textboxRef = ReferenceCell(row, col);
textboxRef.Text = "TEST" + row + ", " + col;
}
}
}
private System.Windows.Forms.TextBox ReferenceCell(
int row,
int col)
{
string cellName;
cellName = "txtRow" + row + "Col" + col;
System.Windows.Forms.TextBox textboxRef;
// get compile error if i do not assign to something
textboxRef = this.txtRow1Col1;
switch(cellName)
{
case "txtRow1Col1":
textboxRef = this.txtRow1Col1;
break;
case "txtRow1Col2":
textboxRef = this.txtRow1Col1;
break;
}
return textboxRef;
}
|
|
|
|
|
redfish34 wrote: switch(cellName)
{
case "txtRow1Col1":
textboxRef = this.txtRow1Col1;
break;
case "txtRow1Col2":
textboxRef = this.txtRow1Col1;
break;
}
I assume that second case is supposed to read textboxRef = this.txtRow1Col2; ?
What you are doing should work. You declare a TextBox variable and give it a reference to the TextBox you're interested in. What exactly do you mean by nothing happens?
|
|
|
|
|
The "nothing" problem was that the first textbox would not update with any text. After fiddling around with the code and recompiling- not really changing anything- everything magically works now. I had this experience with classic VB and ASP. Sometimes things just don't work- then later would work. You scratch your head for hours wondering what the heck you are overlooking. Since i am new to C# i was not sure if the problem was me or the microsoft IDE. I guess i am going to have to get in the habit of recycling the computer power when i run in "mysterious" circumstances again. This is one way to overcome these glitches. FYI, i am using visual studio 2003.
But thanks very much for confirming that i did good. I posted this question on some other forums and got ZERO response. Your help allowed me to rule out "me" as the problem.
|
|
|
|
|
|
You may try this.
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.F12)
{this.button1_Click(this, null);}
}
"I am a lair" Is this statement true or false ?
|
|
|
|
|
I was stumped by this too, but the answer is simple. Assign the Shortcut property of a MenuItem. This means you need a Menu obviously.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
I've got that functionality on a a few larger dialogs, but I wanted help to be F1 even on the small modal ones. LongHC gave exactly want I wanted though.
|
|
|
|
|
Hi All
I have some application that i need to get parameters from the user and open Windows Form in the size that this user choose.
How can i change Windows Form in the run time ? [real time] ?
Thanks.
|
|
|
|
|
If you are changing the parent form then use:
this.Size = new Size ( width, height );
if you are opening a new window then:
Form form2 = new Form();
form2.Size = new Size(300,300);
|
|
|
|
|
Modify the Size atribute.
To have a form resize itself do this:
this.Size = new Size(width,height);
You'll need to look into anchoring (or possiby docking) your controls to grow/reposition them when the form changes it's size. If you're using 05 you could also try the layout manager. In 03 for anything complex you might have to handle the resize event yourself.
|
|
|
|
|
I have a large project that early on a class was defined as "Blocks". There was grandious plans for this class, but as the project developed, "Blocks" became a place for a few constants. I would like to change this "Blocks" to "Constants", but the term "Blocks" is used EVERYWHERE in the program. The only certainty is that if I did a simple search and replace, I would screw at least 100 things up. I heard a rumor there is a smart replace for variable names/etc. I found very little info on it. Has anyone used it. Does anyone know if it will work on classes.
Thanks in advance...
Dwayne
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
If you're using VS2005, it supports refactoring[^]. If not, there are tools available for previous versions of VS, such as this one: ReSharper[^]. I am not aware of any free tools, though truth be told I have never looked for them.
Jon Sagara
As you may presently yourself be fully made aware of, my grammar sucks.
Sagara.org | Blog | My Articles
|
|
|
|