|
Please try writing in proper English, it takes not much more time than using things like "wanna c" for want to see, and ur for your.
|
|
|
|
|
Greetings,
I have a control that inherits from GroupBox and contains some other default controls and behavior. I am trying to override the GroupBox Text property so the text appears in a label in the GroupBox, and have the GroupBox text itself be an empty string. However, when I set the Text property in the designer, both my label and the GroupBox show the same text. What am I missing? I am using C# 2.0 using VS 2005 (I haven't upgraded to VS 2008 because I need at least the Standard edition for building my installers, and upgrading to VS 2008 Standard or Pro is not in the budget at the moment).
public class ExpandableGroupBox : GroupBox
{
public ExpandableGroupBox()
{
base.Text = "";
}
public override Text
{
get
{
return label.Text;
}
set
{
label.Text = value;
}
}
}
Thanks,
Dybs
|
|
|
|
|
Did you copy the source from your Visual Studio direct in here?
If it's like that, you won't be able to compile the code anyway, because you are missing the type of your Text property
public class ExpandableGroupBox : System.Windows.Forms.GroupBox
{
public ExpandableGroupBox()
{
base.Text = "";
}
public override string Text
{
get
{
return label.Text;
}
set
{
label.Text = value;
}
}
}
hack the planet
|
|
|
|
|
No, I typed it from memory, and lack of sleep was setting in. I do have the type in the actual code and it compiles. (If it didn't compile, I couldn't really complain about both my label and the GroupBox showing the same text ).
Dybs
|
|
|
|
|
I have no idea why your code is not working. I would probably tried something similar.
However, take a look at this article[^] (it's got some pretty pictures). Is that the sort of thing that you want?
If not, I found that by Googling c# override text of groupbox, there were lots of hits including UXTheme'd GroupBox control[^], from here on CP. I haven't read it but it might give you some ideas.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry,
Thanks for the links, but the article's aren't quite what I'm after. What I'm trying to make is a GroupBox that will expand/collapse when a header is clicked. In my case I'm using a ToolStrip at the top of the GroupBox , and I want the ToolStrip's label to show the Text property instead of the GroupBox . Rather than inherit from UserControl and do everything by hand, it seemed reasonable to inherit from GroupBox and just override the Text property, and add the expand/collapse behavior.
I've almost got it working now. I tried using new instead of override for the Text property, and it gives me the desired effect, but the value I set in the designer doesn't show up when the application run. It only shows me the default value. It's the same situation described here[^]. The value is not being written to the InitializeComponent method for my form. I tried setting the DesignerSerializationVisibility attribute to Visible , but that didn't work. I've looked at the other attributes listed on MSDN[^], but I don't see any others that I know would help. Here's what my code looks like now:
public partial class ExpandableGroupBox : GroupBox
{
public ExpandableGroupBox()
{
InitializeComponent();
base.Text = "";
}
[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
Bindable(true)]
public new string Text
{
get
{
return toolStripLabel1.Text;
}
set
{
toolStripLabel1.Text = value;
}
}
}
After some more searching, it looks like I may be able to use something like DevExpress's XtraNavBar[^]. However, I'd still like to figure this out just for my own curiosity. Things like this bug me to no end...
Any more help would be greatly appreciated.
Dybs
|
|
|
|
|
A while ago I wrote an article on Nested Controls (which is what the controls inside a GroupBox are) and their design time behavior.
I don't know if you feel that it might have relevance to your situation, but have a look and see. Here is a link Designing Nested Controls[^].
Hope there is something useful in there for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Great article! I ran into this problem with a TableLayoutPanel awhile back (we made the panels all resizable at runtime) and we couldn't figure out how to drop controls into the different panels at design time. This is exactly what we need. Great set of resource links, too. I'll play around with the designer stuff tomorrow and see if I can bend it to my will.
Thanks,
Dybs
|
|
|
|
|
I finally got it to work. I added the Category and DefaultValue attributes, in addition to the code above, and now it's working. Not sure why that would have affected it but hey, I'll take it. Thanks again.
Dybs
|
|
|
|
|
Good stuff!!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Where can I learn more about MyNeoReports? I have a need to develop an app that builds an internal dataset and creates a viewable/printable report. Therefore, I need to build the report completely at runtime without a pre-defined design. It appears as if MyNeoReports will work, but I can't find a tutorial or detailed example code anywhere to point me in the right direction. Any help will be greatly appreciated.
|
|
|
|
|
Does A New .NET Reporting Way[^] not help?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hey there,
i am programming a charting Libary for my Financial Suit. Therefore my idea was to have a Panel that has List s of all my shapes (Line, Pie, Bar etc.)
Wenn i resize my Panel the whole shapes are flickering very much.
i googled and codeprojected a few days but i got no satisfying answer.
Control.SetStyle(ControlStyles.OptimizedDoubleBuffer, true)
...does unfortunately not work, because, when i set this style, the shapes only appeare frequently on resizing, but when the resizing is finished (MouseUp ) the Panel is empty (white; and if i override the OnPaintBackgound and comment the base.OnPaintBackgound out it is black)
Does anyone know about this problems or had the same?
Do i need some more Styles etc?
Do i have to override some methods or properties?
[Edit]
Hey there,
i finally figured it out:
the problem is, if i use Control.SetStyle(ControlStyles.OptimizedDoubleBuffer, true) and an object uses Control.CreateGraphics() it will only be painted while resizing and not when resizing is finished! Now i'm using public void Draw(Graphics g) instead of public void Draw(ChartingSketch sketch) and now it works!!
[/Edit]
hack the planet
modified on Sunday, September 13, 2009 4:28 AM
|
|
|
|
|
Without seeing at least some of your painting code, it is almost impossible to say.
Post the relevant parts of your code (enclosed in PRE tags, please), so that people can try to help.
There is no need to reply to this, just edit your original post.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
because drawing in memory’s speed is much slower than showing to screen.
lead to Delay.
iam so glad to see you override the 'OnPaintBackgound ',
1) but i think you should can set 'form's double buffer property' to 'true',
2) or use a 'bitmap' to simulate 'double buffer'.
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:02pm.
|
|
|
|
|
Hi,
I need help with changing background image of WinFrom run time.
But i want to change the background image of selected area only not for whole form
the area is not just like square or rectangular or circle like that
for example i have passport size photo and in that at run time i want to change the image of face only
(Something like creating hotspot and changing the image of that spot only at run time )
i know this can be done if adobe photo shop.
is this possible in winform ?
if no then whether it is possible in asp.net ?
|
|
|
|
|
All I can think of is using DrawImage method of the graphics class and then covering the unwanted parts using Graphics object.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
if you change background image frequently in winform, will lead to ‘out of Memory’ exception.
you should consider to draw image by 'GDI+'.
of course, asp.net is possible to do it.
if you think it's hard to achieve it. try to learn 'silverlight'.
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:03pm.
|
|
|
|
|
Hi!
Have you used or know of any logical expression editor controls? Some thing like whats seen here.
Googling for it did not turn up anything i could work with.
Any pointers in the right direction would be much appreciated.
Thanks!
|
|
|
|
|
Hi,
I’m developing a windows application using VS 2005. I’m getting a different icon on my task bar than I have in my title bar at runtime. I’ve recently edited my Icon. The Icon that displays down in the taskbar is the ‘old’ version of the icon and the icon in the title bar is the new version (Note: the icon in the taskbar is just a regular icon, I’m not working on a NotifyIcon). I’ve searched my application directory and I don’t see the old icon anywhere.
Could it be coming from a .dll or the GAC instead of the form’s .resx file?
Why would the tab have a different icon than the title bar?
Has anyone seen or heard of this type of behavior before?
Thanks,
Andy
|
|
|
|
|
Hi,
Some comments on applications and icons:
1.
An application typically has two different icons:
- the application itself has an icon at the file level; it gets used by Windows Explorer; you set it as a project property. (right click the project in the solution pane, choose application tab, and specify the icon file/resource there)
- any form can have an icon; it is a Form property, that you can set through Visual Designer. It also shows up in the task bar's button (if the Form shows in task bar). A form’s icon, when set by Visual Designer, gets stored in the Form’s resx file.
2.
You can set a Form’s icon programmatically. An easy way to do that consists of:
- add the ICO file to the project;
- give the file the Build Action “embedded resource” so it gets included in the app’s resources.
- use one of the Icon constructors to get the icon resource, as in:
this.Icon=new Icon(this.GetType(), "name.ico");
- if the icon file is not at the top-level of the solution, add its relative path to the icon name; so if it resides in directory “resources”, change the above constructor statement to …"resources.name.ico");
3.
an icon file can hold multiple icons (icons at different sizes), and Windows will pick one depending on circumstances, so if they do not all look alike, you may get very confused.
4.
I tend to create icons programmatically; the following code converts a (best small,
square) image into a simple icon:
string filename=popupNode.getLongName();
try {
Bitmap bm=(Bitmap)Image.FromFile(filename);
if(bm.Width!=32 || bm.Height!=32) {
bm=new Bitmap(bm, 32, 32);
}
Icon icon=Icon.FromHandle(bm.GetHicon());
bm.Dispose();
string filename2=Path.ChangeExtension(filename, ".ico");
Stream stream=new FileStream(filename2, FileMode.Create);
icon.Save(stream);
log("Created icon "+filename2);
} catch(Exception exc) {
log("Failed to create icon from "+filename);
log(exc.ToString());
}
|
|
|
|
|
Thanks, that helps!
|
|
|
|
|
you're welcome.
|
|
|
|
|
when you use the icon at the first time.
it had been imported into .resx file.
so you should open the file, and delete the icon.
(you should look up toolbar's background-Image Property,
may be you will see the icon)
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:02pm.
|
|
|
|
|
I have been wrestling with a problem for about four days now, and quite honestly I think it's winning. I'm down by two falls to one at the moment.
Since song parodies were mentioned in The Lounge recently, I thought I'd have a go.
My application won't compile
I've searched the thing all over the place
Googled till I was black in the face
I'm a big disgrace t' the Programmer race
My Application won't compile
You see what it's done, it's reduced me to a gibbering wreck.
Here's the problem.
I have a generic class, to save you reading through loads of code, for this explanation pretend that it is a Stack<T> , since the result is the same.
Now I want to create a Control StackVisualizer that can show a graphical representation of any Stack<T> . You know a set of vertically aligned boxes representing the items in the Stack<T> , so that you can see what happens with Push and Pop etc.
public partial class StackVisualizer : UserControl
{
private Stack<T> workingStack = null;
..................
..................
..................
..................
}
That doesn't work, because T is not known at compile time.
OK so lets try:
public partial class StackVisualizer<T> : UserControl where T : IEnumerable<T>
{
private Stack<T> workingStack = null;
..................
..................
..................
..................
}
Now this works, but StackVisualizer is no longer a visual control. I can put it on a Form and set its properties etc. but I have to do it in code, I cannot do it in the Designer.
Does anybody have any ideas?
Plzzzzzzzzzzz give me teh codezzzzzzzzzzzzzzzzzz!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Wednesday, September 9, 2009 2:13 PM
|
|
|
|
|