|
When you inherit from Panel,if you want to add controls just double click on a controls on toolbox and they added to your form,then you should manully set the positions , size and other properties in code-behind. Whats your problem with it?
Mazy
No sig. available now.
|
|
|
|
|
When you inherit from Panel, you lose the design view in VS.NET. That was my problem.
And when I lose the design view, I can't just add controls visually because it just doesn't work right anymore.
But fortunately Jose gave me the solution, by added some attributes to the custom control.
Thanks anyway!
|
|
|
|
|
If you can't use the designer, just code the controls manually.
As far as displaying custom panels (or any scrollable control, for that matter), derive your custom panel Types (classes) and store the Type of the derivative panels as properties of the item on which the action occurs, such as clicking on a menu item. Since you're dealing with MenuItem s, also extend MenuItem with your own class and add a property, kind of like:
public class MyMenuItem : MenuItem
{
private Type panelType;
public MyMenuItem() : this(null, null) {}
public MyMenuItem(string text) : this(text, null) {}
public MyMenuItem(string text, Type panelType) : base(text)
{
this.panelType = panelType;
}
public Type PanelType
{
get { return this.panelType; }
set { this.panelType = value; }
}
} Treat this menus like normal, adding them to a MenuItems collection just like normal. When a user clicks on the MenuItem , you will use that Type as you'll see shortly. For brevity, assume that each MenuItem uses the same Click event handler:
private void menu_Click(object sender, EventArgs e)
{
MyMenuItem menu = sender as MyMenuItem;
if (menu != null)
{
if (menu.PanelType != null)
{
Panel p = Activator.CreateInstance(menu.PanelType) as Panel;
if (p != null)
{
p.Dock = DockStyle.Fill;
leftContainer.Controls.RemoveAt(0);
leftContainer.Controls.Add(p);
}
}
}
} This is just a very basic example but I hope you get the idea. Creating instances of unknown Types (or from a collection of Types, perhaps configured in a .config file) is fairly common. I do this A LOT in our enterprise app I designed. It goes much deeper than this, but this is the essential idea.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
You can create a new class A inheriting from Panel adding the next lines of code. After that all the classes inheriting from A will have again the design view.
<br />
[Designer(typeof(System.Windows.Forms.Design.DocumentDesigner),typeof(System.ComponentModel.Design.IRootDesigner))]<br />
public class A : System.Windows.Forms.Panel<br />
{<br />
....<br />
}<br />
...<br />
public yourpanel : A<br />
{<br />
....<br />
}<br />
|
|
|
|
|
Thanks to all responses to my questions!
Jose Fco Bonnin gave me just what I needed! After making my own custom panel type I inherited from that to create a panel I'm going to use in a winform app and it did show the design view again, great!
|
|
|
|
|
I have listbox that view data where the order of this data is important, so i need to add two buttons, to allow the user to change the item index in the listbox
the first button will decrease the index by 1 (up)
and the other will increase it by 1 (Down)
and i do know how to change the index number
thnx in advance
|
|
|
|
|
Thank u
I did it my self
and here is the code
private void btn_up_Click(object sender, System.EventArgs e)
{
if(this.lb_target.SelectedIndex != -1)
{
if (this.lb_target.SelectedIndex != 0)
{
object tempob=this.lb_target.SelectedItem;
int index=this.lb_target.SelectedIndex;
this.lb_target.Items.Remove(this.lb_target.SelectedItem);
this.lb_target.Items.Insert(index-1,tempob);
this.lb_target.SelectedIndex=index-1;
}
}
}
private void btn_down_Click(object sender, System.EventArgs e)
{
if(this.lb_target.SelectedIndex < this.lb_target.Items.Count-1)
{
object tempob=this.lb_target.SelectedItem;
int index=this.lb_target.SelectedIndex;
this.lb_target.Items.Remove(this.lb_target.SelectedItem);
this.lb_target.Items.Insert(index+1,tempob);
this.lb_target.SelectedIndex=index+1;
}
}
|
|
|
|
|
i wanna to know the tool or the class that we can use in c# that we can make fullscreen game animation as that in the openGL
tona
|
|
|
|
|
You have to have DirextX9.0 SDK. And when you install it there are some samples with it which you canfind your answer there.
Mazy
No sig. available now.
|
|
|
|
|
or just use CsGL(OpenGL Port to C#)
csgl.sf.net
scio me nihil scire
My OpenSource(zlib/libpng License) Engine:
http://sourceforge.net/projects/rendertech
Its incurable, its a Pentium division failure.
|
|
|
|
|
Dear, Sir
I launch Calculator by the following code
System.Diagnostics.Process.Start("calc.exe");
How to active the Calculator I have launch again when I press a button on my App.
Thank You.
Sorry for bad English.
|
|
|
|
|
I think what you want is to activate the calculator app. you have already launched through code, without launching another instance of it.
For this you need to use FindWindow api to determine whether you have the application(calc) active and then activate it by SetFocus API.
You need to pass the handle returned by FindWindow function to the SetFocus API. You need to P/Invoke for calling these two API's.
Cheers,
Kannan
|
|
|
|
|
I'm really frustrated with this. The images looks fine under edit mode, but they all disappeared when the application is running. What happened?
I know there is a solution about adding "Application.DoEvents()" after "Application.EnableVisualStyles()", but it doesn't work for me...
Anyone has an explanation? Thanks!
|
|
|
|
|
Does it work if you dont call Application.EnableVisualStyles()?
I have stopped using that, and just put a manifest file together with my app, much less problems...
- Anders
Money talks, but all mine ever says is "Goodbye!"
My Photos[^]
|
|
|
|
|
I have tried all, with or without EnableVisualStyles(), with or without manifest file. Nothing works.
It actually worked for me for a while, but at some point during coding(probably after I changed the font to some labels on the toolbar), it disappeared and would never get back.
Anders Molin wrote:
Does it work if you dont call Application.EnableVisualStyles()?
I have stopped using that, and just put a manifest file together with my app, much less problems...
|
|
|
|
|
|
After a research using Diff tools, I found the problem was the font of the tool bar. It worked fine under default font, but if I change it to any other font, even after I changed it back to the original default font, the images on toolbar will disappear!!!
I don't know why, it's probably a bug of Microsoft.
I wrote a small Windows Form app, it works fine. It's only in my application that the font change will affect the toolbar images.
Thanks,
Jason
|
|
|
|
|
Hi,
In VC++ 6, I can put "\t" in the text of a static control and it will show as a tab. But in VC# .Net, it doesn't work for me? How can I insert a tab?
Thanks!
|
|
|
|
|
Assigning a string to Label.Text (which inherits form Control.Text ) internally calls the SetWindowText native function (most controls encapsulate common controls and Windows Management APIs). SetWindowText does not expand tab characters.
To get this effect, you might consider extending Label and overriding the OnPaint protected method (when extending, override the methods that raise the corresponding events instead of handling the events - it's faster and gives you more control (like deciding whether or not to call base.OnEventName )).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a form where I have assigned the left and right cursor keys to perform functions, using the following code:
private void SAPtastic_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
e.Handled = true;
switch(e.KeyCode)
{
case Keys.D1: movecopysap("1"); break;
case Keys.D2: movecopysap("2"); break;
case Keys.D3: movecopysap("3"); break;
case Keys.D4: movecopysap("4"); break;
case Keys.D5: movecopysap("5"); break;
case Keys.D7: movecopysap("Unclassified"); break;
case Keys.NumPad1: movecopysap("1"); break;
case Keys.NumPad2: movecopysap("2"); break;
case Keys.NumPad3: movecopysap("3"); break;
case Keys.NumPad4: movecopysap("4"); break;
case Keys.NumPad5: movecopysap("5"); break;
case Keys.NumPad7: movecopysap("Unclassified"); break;
case Keys.Space: movecopysap("Unclassified"); break;
case Keys.Back: if (apnt > 0) {apnt = apnt - 1; LoadnScale();} break;
case Keys.Left: if (apnt > 0) {apnt = apnt - 1; LoadnScale();} break;
case Keys.Right: if (apnt < (al.Count-1))
{apnt = apnt + 1; LoadnScale();} break;
case Keys.Home: apnt = 0; LoadnScale(); break;
case Keys.End: apnt = al.Count -1; LoadnScale(); break;
default: e.Handled = true; break;
}
}
The odd thing about this was that whilst I did create an override on IsInputKey to allow me access to the cursor keys, it is never called - if I remove it there is no difference to the operation of the program.
That is not the REALLY WEIRD THING, I added a toolbar at user's request and now the cursor keys need to be pressed twice in order to get them to function. The above code is not called on the first keypress, but is on the second.
I gets worse... I included an option to not display the toolbar, if the toolbar is disabled - the keys work fine!
Any assistance would prevent me having yet another sleepless night and so would be much appreciated!
Chris
|
|
|
|
|
Is this code in a Form to handle the various inputs? If so, set Form.KeyPreview to true . Since child controls will have the focus, the parent Form will not receive key notification messages unless KeyPreview is true .
I'm not sure why the toolbar would change things, but I'm guess that internally (the native Toolbar common control) is that it routes messages to the parent, perhaps causing other child controls to do it, too. Not sure, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the reply - I was beginning to wonder if anyone would answer my plea!
That property is already set, I too am unsure why the addition of the toolbar would change things. With this in mind I returned to a previous version of the code before the toolbar was added, the mear addition of the toolbar without adding buttons or changing settings resulted in the same behaviour.
I may have to replace the toolbar with a groupbox and ordinary buttons ;-(
|
|
|
|
|
I have been trying to monitor the handshake (signal) from
a printer for each page it printed but i have not been
able to do so. Can any out there help me.
|
|
|
|
|
That might be a little too low level for C# to handle easily. In the Windows DDK there are a set of parallel port functions you can try to hook into (like IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO ) but I don't think any of them have been exposed in C#. And that assumes that you are using a parallel port printer.
If you are doing lower level OS I/O, C# tends to be a poor choice to use. The abstraction layer PrintDocument is there to avoid the messy OS level details of talking to the hardware. Why are you interested in the hardware communication?
|
|
|
|
|
Am interested because am writting a printer monitoring program that will monitor the printerout from any printer.where am having problem is getting the actual number of pages printed and also to be able to know when a page is printed in a situation where there is more than one page of the document.
|
|
|
|