|
Thanks again!
Rob Philpott wrote: The right and bottom line are probably not appearing because they're outside the clip rectangle
I use the Inflate(-2, -2) to make sure the Rectangle was inside the clip rectangle,but they're still not appearing.
follow is the test code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace draw
{
public partial class Form1 : Form
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1.SuspendLayout();
this.SuspendLayout();
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Location = new System.Drawing.Point(192, 141);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 100);
this.panel1.TabIndex = 0;
this.groupBox1.Location = new System.Drawing.Point(91, 43);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 100);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(674, 358);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.GroupBox groupBox1;
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Control ctrl = groupBox1;
Control ctrlP;
ctrlP = ctrl.Parent;
Rectangle r = ctrl.Bounds;
Rectangle rP = new Rectangle(0, 0, ctrlP.Width, ctrlP.Height);
r.Intersect(rP);
r.Inflate(-2, -2);
Graphics g = ctrlP.CreateGraphics();
Pen p = new Pen(Color.Red);
p.Width = 1.5f;
g.DrawRectangle(p, r);
g.Dispose();
}
}
}
|
|
|
|
|
I think the cause is the graphics,which belong to panel1(the parent of groupbox1),we drawed the rectangle on the panel1 but it just under the groupbox1.So the rectangle we drawed were cover by the groupbox1.
|
|
|
|
|
I'm not sure I like the look of this. You appear to be painting on the groupbox in the paint event of the form. Really you should only use that to paint areas of the form that don't have controls on them. You'd need to do that paint in the groupbox's paint event, not the form one.
Likelyhood is that the groupbox paints itself immediately after the form. Do you get flicker at all?
Regards,
Rob Philpott.
|
|
|
|
|
change the p.Width = 1.5f; to p.Width = 10f;
you can see the left and top line were drawed.
|
|
|
|
|
Hi,
I want to ask a question about GUI designing in C#
I have a project to do , and it has only a few forms to show
and it is very important to have a very special and also very beautiful GUI
I want to know is it better to have a GDI+ and/or have a System.Drawing or/and
it is better to have a custom Control
help me please
thank you all
|
|
|
|
|
cppwxwidgetsss wrote: I want to know is it better to have a GDI+ and/or have a System.Drawing or/and
it is better to have a custom Control
WPF is a good choice if you need beautiful UI.
|
|
|
|
|
...f is a Form
Control t_ctrl;
for (int i = 0; i < f.Controls.Count; i++)
{
t_ctrl = f.Controls[i];
TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text);
t_tn.Tag = t_ctrl;
self.treeView1.Nodes.Add(t_tn);
addNode(t_ctrl, t_tn);
}
...
private static void addNode(Control ctrl, TreeNode tn)
{
Control t_ctrl;
for (int i = 0; i < ctrl.Controls.Count; i++)
{
t_ctrl = ctrl.Controls[i];
TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text);
t_tn.Tag = t_ctrl;
tn.Nodes.Add(t_tn);
if (t_ctrl.Controls.Count != 0)
{ addNode(t_ctrl, t_tn); }
}
}
but is not full,some controls not got into the treeview1.such as ToolStripMenuItem.
somebody can give me some tips or advises.Thanks!
|
|
|
|
|
You should use a foreach, and you should write a recursive method, because some controls, contain controls.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for your reply
I had already use the recursive method-->"addNode(Control ctrl, TreeNode tn)"
|
|
|
|
|
Controls inside a tool strip aren't available from the Controls property, you need to use the Items property instead.
|
|
|
|
|
So if I want to make it, I need to consider all those special controls,
It's not a easy thing,right?
Did anybody have idea about how display all controls in winfroms at runtime like vs2005 doc outline tool in designtime?
|
|
|
|
|
hwswin wrote: It's not a easy thing,right?
As there's no common interface to access child controls, I'm afraid not.
|
|
|
|
|
Does any one know of a Development tool that can create Command Shells or loadable modules in windows for C# for a server.
|
|
|
|
|
Hi all
I'm creating a web browser in C# and i've pretty much got what I needed and I keep getting stuck on one thing. When I'm browsing the web in my new browser and stumble upon a link that opens a new page in a new browser, or in a new tab or whatever, it opens that new page in internet explorer! lol. How can I stop this? It's really getting on my nerves, but it's making me laugh at the same time... I want to do something like this (and yes, i know this code will never work :p):
if Link is trying to open new page in new tab or window
then open that new page in a new tab in the current window.
... I know how to create new tabs, add a new webbrowser control to the new tab etc, i just don't know how to get those particular links to open up in a new tab. Does anybody have any ideas as to how I might go about doing this? I have looked on msdn and couldn't find anything. I also tried google and found a few links but then led me to something completely unrelated.
thanks,
jase.
modified on Thursday, June 11, 2009 1:44 AM
|
|
|
|
|
I need to write a development environment (editor) for writing ladder logic programs for PLCs. This is prt of a larger project. I can find no information anywhere on the net that could possibly point me in the right direction.
If anyone cangive me some direction as to where to look I would greatly appeciate it.
I am developing in C# and that is why I have chosen this forum.
Thanks,
Jim
|
|
|
|
|
There is a syntax highlighting control on CP, but it's in c++. I used it ages ago on a Python IDE.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
here are two suggestions:
1.
come up with functional specs
2.
do some research[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Your link to research only points out the lack of available information on the subject. All these links are for already developed editors. I need to write a new one.
|
|
|
|
|
JimLaVine wrote: All these links are for already developed editors.
Did you even try looking at/for the source code for some of them?? It's amazing what you can find by examining the source of another editor.
|
|
|
|
|
JimLaVine wrote: I need to write a development environment (editor) for writing ladder logic programs for PLCs.
No you don't. You could download the Visual Studio Shell, and write your own language here, using the Language Integration capabilities in Visual Studio.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Problem occurs when I exit out of the application.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Whatever has been written to my config file and saved to the file
goes back to what it used to before.
I have no idea why ? Do you guys have any idea?
System.Configuration.Configuration config = null;
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(strJob, strValue);
config.Save();
|
|
|
|
|
Your asking for information that applies to all users, by specifying ConfigurationUserLevel.None . Not a per user level, which is what your trying to save.
Try the other types.
Also settings should be user level and not application level. Or they'll never change anyway.
Using the wrong tool for the job is half the fun.
|
|
|
|
|
Tried
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
crashed at Config.Save.
|
|
|
|
|
Hey all
Does anybody experience flickering of the desktop icons, application window icons (any open application) whilst visual studio c# express is running? like for example i'll go to debug and then if i open a context menu or do anything in my program everything on my computer starts to flicker. Desktop icons, icons inside programs, and other controls such as comboboxes buttons etc? I don't have any viruses/trojans or anything like that so I'm puzzled. And it only just started happening. I've never had this problem before, I do remember though reading on here a while ago about someone who had the same problem but don't remember any solutions or anything...
jase.
|
|
|
|
|
i have a program that authenticated users with Active directory how do i query AD to find out when is the last time a user was authenicated i trided using last logon time but this is only updated when they log on to the computer not when the authenticate
|
|
|
|