|
Hi everyone,
I am at wits end. I think I've read every article on CP and searched for them on the web and I just can't figure this out. I have built an application that has a lot of group boxes and controls within those group boxes on the form. I designed it with a screen resolution of 1280x1024 in mind because that is what all of us use. The controls fit just right when maximized. Now, I get this one user who is still using 1024x768 and I'm hosed!
There are some group boxes and some comboboxes/textboxes that I can resize and make smaller (when they entered data, it would scroll out of the box, but no big deal).
So now I have to re do this application to make it so that it resizes certain controls in certain group boxes when the form size is changed. (ie, they resize the control, I need one of the group boxes to get bigger, and a control or two within that groupbox to get bigger too)
I have tried playing with DOCK and ANCHOR on end. I can't get it to work right. Setting an anchor property of TOP,LEFT,RIGHT,BOTTOM resizes the group box that I want, but the problem is that when it is resized too much, that group box runs into the next group box below it. I just cannot figure out how to use panels, flowlayoutpanels, dock and anchor properties to only resize some controls but do not interfere with other controls (there are buttons / textboxes next to each other, and above and below each other, each time I've tried one of the buttons will resize itself and overrun the next) I can't get them all to just work nicely with one another!
I went to the store and bought two books and read for three hours today before posting this. I'm super peaved at myself for not being able to figure this one out. Any help, a link or anything would be seriously appreciated!
TIA
|
|
|
|
|
It's really difficult to visualize by your post the problem you're having. Can you post the code for the form or show a screenshot of the problem? Most likely if you need resizing but don't want your controls to overlap other controls in the same parent via the resizing, you'll need a flow layout panel. But I'd really need to see what you need visually before answering your problem.
|
|
|
|
|
Apologies if this is basic but I can't make much sense of most of my searches (and I'm pretty much brand new to C#). I appreciate your help in advance.
Problem:
I have a picturebox (pictureBox1), which I want painted in a blended form from say silver at the top to red at the bottom.
I am aware of something like linear gradient brush but I can't get the syntax right. I get to a point where I write this:
//-----------------------------------------------------------------------
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
// nothing I try here seems to work!
}
//-----------------------------------------------------------------------
but nothing I try between the brackets seems to work, apart from "pictureBox1.BackColor = Color.Purple(or whatever)", but that's not what I'm after, I can't get a blending working. I know I have to create a brush somehow and tell it to paint it in a blending manner linearly from the starting color to the ending color, but I can't get the syntax right.
Can anyone give me some clues/a hand for/with the syntax? Thanks!
Rodrigo
P.S. Out of curiousity, does anyone know how to create custom shaped buttons?e.g. instead of having the window close button as a square having a button that's a half-moon shape or something. Cheers.
|
|
|
|
|
|
elsombreron wrote: P.S. Out of curiousity, does anyone know how to create custom shaped buttons?e.g. instead of having the window close button as a square having a button that's a half-moon shape or something. Cheers.
round buttons[^]
Alex
|
|
|
|
|
I have a Main Form that calls various subforms with the following code on a button:
private void btnForm2_Click(object sender, EventArgs e)
{
using (frmForm2 frmform2 = new frmForm2())
{
Hide();
frmform2.ShowDialog();
Show();
}
}
Then I have a single button on the other form(s) that has this code:
private void btnOK_Click(object sender, EventArgs e)
{
this.Close();
}
Everything works great the first run through. I click the button on the main form and it goes away and I get the other form. I click ok on that form and go back to the original. Great! But then if I click to go back to the same form or any form off of the main again. Once that form comes up and I click OK again <poof> nothing comes back. As that form closes the original seems like it might briefly be displayed (I see maybe a quick outline of it) before going into never-neverland. The application itself never exits and Im still in debug mode then.
I'm obviously doing something really stupid here... Any ideas?
|
|
|
|
|
I cant reproduce your problem. Please check if the MainForm goes behind any other windows that might be open (like Visual Studio).
---
"Drawing on my superior command of language I said nothing."
|
|
|
|
|
Well I did say it must be something stupid. Ok yes I have 100 things opened and it was beneath them, but I suppose essentially the same question comes around. Why do I get one result the first time through (The Main Screen shows back on top) and the second run through it does something totally different (The Main Screen shows behind other Windows). Or I suppose, more importantly, how do I fix it?
|
|
|
|
|
use BringToFront property of your main form
e.g.
Form2 frm = new Form2();<br />
this.Hide();<br />
frm.ShowDialog();<br />
this.Show();<br />
this.BringToFront();
|
|
|
|
|
Yeah that solves the problem, though I dropped all the "this." I just don't know why I've never had to do this in the past. Or why it works on the first run through and back but not the second. I guess I'll just chalk it up to some kind of quirkiness in the MS C# 2005 Express Ed. Debugger. I just "upgraded" to it from a full 2003 version yesterday
|
|
|
|
|
Let's say i have an class boo with the properties foo, baa, coo etc ...
From a function I get a string returned of the property name of wich I have to get the value of.
Then I shoud program it this way:
<br />
string returnedPropertyString;<br />
boo temp = new boo();<br />
<br />
switch (returnedPropertyString) {<br />
case "foo":<br />
return temp.foo;<br />
break;<br />
case "baa":<br />
return temp.baa;<br />
}<br />
Now I wonder if there isnt a nicer way to do this like eg in flash:
<br />
string returnedPropertyString;<br />
boo temp = new boo();<br />
<br />
return temp.[returnedPropertyString]
Would be verry usefull, because I have lots of properties and subproperties in my boo class so it would be almost a endless switch statement
|
|
|
|
|
You can do this with reflection:
Type booType = typeof(boo);
PropertyInfo desiredProperty = booType.GetProperty("thePropertyName");
return desiredProperty.GetValue(temp);
|
|
|
|
|
Thanks, it worked
But since i work with it in Linq, i've made it an function in my class.
For those that are interested, I use it this way:
<br />
<br />
public object GetValue(string property) {<br />
Type x = typeof(clsHotel);<br />
PropertyInfo p = x.GetProperty(property);<br />
return p.GetValue(this,null);<br />
}<br />
<br />
<br />
switch (regel[1]) {<br />
case "=":<br />
case "is gelijk aan":<br />
lijst = from d in lijst<br />
where (string)d.GetValue(regel[0]) == regel[2]<br />
select d;<br />
break;<br />
}<br />
return lijst;<br />
|
|
|
|
|
You can use indexer properties for wrapping that up.
For example
public object this[string propertyName]
{
get
{
Type booType = typeof(boo);
PropertyInfo desiredProperty = booType.GetProperty(propertyName);
return desiredProperty.GetValue(temp);
}
}
object boo = foo["boo"];
Isnt this simple?
|
|
|
|
|
I've created this windows user control:
public class ToolStripMenuItemRol : ToolStripMenuItem
So it still supporting all the native properties of the ToolStripMenuItem. The enhacement applied in this user control was a new property:
private List<int> _roles = new List<int>();<br />
<br />
[Description("Listado de roles válidos para usar este menú")]<br />
[Category("Security")] <br />
public List<int> Roles<br />
{<br />
get { return _roles; }<br />
set {_roles = value; }<br />
}
Then the property Roles appears in the Properties Page in Design mode. And when I'm trying to edit this property in design time, a collection editor appears and work fine. Everything's good up here. But when I close the collection editor, the value entered is cleared, so I reedit, and the collection appears empty. The value of the property Roles is losted; it is not been saved. What should I do in order to persist the data registered in the collection editor?
Open mind for a different view.
|
|
|
|
|
Hi,
I have a ListView in "details" mode in which I programmatically add items and display the items with a gray forecolor. I also set HideSelection to false. Everything is fine until I click outise the ListView (so the list loses focus). Whenever I do this, the selected item's ForeColor becomes black.
This also happens when I click inside the list where there are no items (so the list still has focus, but the selection goes away): the previously selected item's forecolor will become black.
Has anyone seen this behavior? Any ideas?
thanx
|
|
|
|
|
Hello everyone,
I recently noticed a strange thing in one of my programs.
After loading the program, the task manager shows memory usage of about 2mb-5mb.
When I minimize my app to tray, the memory usage goes down to 400kb-600kb.
First of... Why is that?
And second...
If I use a certain function in my app, usage jumps back up.
I show the form again, then minimize it to tray again... Usage goes down again...
My theory is that the memory holding GUI data is released.
Any ideas?
Thanks in advance,
Shy.
|
|
|
|
|
That's not strange at all.
When you minimise the program, the memory management in the .NET framework will try to release as much unused memory as possible back to windows. This may include doing a garbage collection to release unused objects. Also the system may swap out rarely used memory areas to the swap file on disk.
If you also bring up the column "Virtual Memory Size" in the task manager, you will see the total memory amount used, including the swapped out memory.
If you use a part of the program or data that has been swapped out to disk, it will be brought back into physical memory, bringing up the memory usage, but not the virtual memory usage.
---
b { font-weight: normal; }
|
|
|
|
|
Actually, it does that for about every application; it's a feature of Windows XP & 2000 IIRC.
|
|
|
|
|
At least the OP's program is giving memory back rather than keeping it and sucking the life out of system resources.
|
|
|
|
|
I have a custom Windows Forms Control. I'll call it "JealousControl".
I want to make it so that if the user puts focus on JealousControl and tries to change focus to another control on the Form that hosts JealousControl, it won't let the user do that except in very specific situations. Furthermore, I want the code that does this to be internal to JealousControl and not inside the Form that hosts JealousControl.
Does anyone know if this is possible (and if so, how)?
|
|
|
|
|
I just experimented with:
private void listBox1_Leave ( object sender , EventArgs e )
{
if ( System.DateTime.Now.Minute <50 )
{
((System.Windows.Forms.Control) sender).Focus() ;
}
}
See if that does what you want.
|
|
|
|
|
|
hi
does anybody take a refrence of how to use Sql Server 2005 Reporting Services in VC# 2005 ?
thanks
|
|
|
|
|
I've recently re-realized that the File Types editor for deployment projects is a POS. Associating an EXE with a file type instead of with individual commands makes no damn sense. So, to have two commands on one file type, each using a different EXE, I have to create registry entries for the second manually.
Problem is, I need to insure that the value dumped into that registry key is sensative to where they choose to install. I could swear that some time ago I saw a list of deployment project variables that could be used, like the [Manufacturer] variable. But I can't find it, and I don't know that they work in registry values.
Does anybody know what all the variables are? And if they can be used in a registry value?
|
|
|
|