|
All you really need to do is create a form and set your default properties. When you create a new form, use the "Add Inherited Form" option in the context menu. That's all. When you add controls to the parent form, set the visibility to protected , instead of private . That will allow child forms to modify them.
Michael Flanakin
Web Log
|
|
|
|
|
Thanks, but...
first of all ... happy new year 2006
here is what i did.
i created a base form.
and created an new item 'inherited form' and pointed to the base form to be interited. is that what u meant?
if so then, the problem is i cannot design it in visual studio. is it so or i am doing something stupid.
regards,
rnv
|
|
|
|
|
What changes did you make to the base form? Try creating a new form and recreate your original incrementally, to see if there's something specific that breaks its designability. If your current base form is set as abstract , remove that. It doesn't have to be abstract and that could be what the problem is.
Michael Flanakin
Web Log
|
|
|
|
|
Hi there.
I am having some problems printing. I made a form with some Label controls and other stuff. The problem is when I want to print, only what fits to one page gets printed out but nothing outside of the first page. For instance, a Label controls has the coordinates 65, 1650 doesn´t get printed but is shows up on screen. I know about HasMorePages but I just don´t know how to use it. I just need to be able to print out two pages, the first one is no problem but the second one is a problem, it doesn´t get printed at all
Can someone please help me?
Thanks in advance,
FJ
|
|
|
|
|
Try this:
//Set the PrintDocument object property.
//This sets the pages to be printed
//Gets or sets the page number from which to start printing
printDocument1.PrinterSettings.FromPage = 1;
//Gets or sets the page number to which to print
printDocument1.PrinterSettings.ToPage = 2;
//This will print 2 pages from 1 to 2.
:->
|
|
|
|
|
Hi, thanks for your help.
Does this mean I don´t need to set the HasMorePages property?
FJ
|
|
|
|
|
Hi.
I just tried what you suggested but the outcome is still the same I do not know how to use the HasMorePages property. Do you have any ideas?
In the program the stuff that comes on the second page doesn´t have to appear on screen, it would be just fine to let it only be printed out after the first page which would contain what is on the screen.
Any help is appreciated.
FJ
|
|
|
|
|
Here is an simple ideea on how to use the HasMorePages property.
Declare a global variable that rembers the current page number (optional).
In your print procedure do the adecvate printing taking account of the page borders. If your drawing must go onto the next page (mening that you encountered the end of the page), set the HasMorePages to true and return from the proedure. Afther returning if the misterious procedure is setted to true the print procedure is called again with another page as an argument.
Yes, in this algorithm you must take account of the page numer (or any other relating element) in order to achive a desired result.
If you created an page number variable, before returning from the print method remember to increment the page.
Hope this helps.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
private void Document_PrintPage(object sender, PrintPageEventArgs e){
e.HasMorePages = true;
}
HTH!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Hi.
I did try this but I couldn´t manage to make it work for some reason. I set the HasMorePages property to true after the printing code for the last item on my page. Then I added what I wanted on the second page and at the end of that code I set the HasMorePages property to false to stop the printing. Despite this my printer only prints out one page
What am I doing wrong?
FJ
|
|
|
|
|
Check this out:
http://www.devarticles.com/c/a/C-Sharp/Printing-Using-C-sharp/
|
|
|
|
|
Can we have a splitter between two panels. one panel's dock property is set to left and other ones set to fill. The splitter does not seem to work properly for the panels I suppose.
Any ideas on how to approach the problem would be appreciated.
Thanks,
VPMahank
|
|
|
|
|
I have run into this same issue. I resolved it by creating my own "splitter" (a very narrow panel control) and keyed off its mouse events (mousedown, mousemove, mouseup), then moved the affected panels accordingly.
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
Thanks for the idea Darryl. I will try it out.
Thanks,
VPMahank
|
|
|
|
|
I tried your suggestion. The idea works!!!. But the painting is not done neatly. I mean I have a inherited panel and I did set the styles to enable doubleBuffering. But using those panels would not paint properly when using the spiltter( I inherited splitter control from label and set the styles for this too). Please let me know if I am missing anything.
Thanks,
VPMahank.
|
|
|
|
|
Are you resizing your panels as you move your splitter? I did not do it that way.
I would allow the user to move my splitter (panel) then when they release I then resize the other panels.
I'm not sure what you did with "I inherited splitter control from label...". I just dropped a panel on my form, made it very narrow (so it looks like a splitter) and allow the user to click on it and drag it to the desired location and release it. At that point, I just resize the panels affected by the new location of the splitter.
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
You havn't described "How it doesn't work". I has used it and everything is expected.
|
|
|
|
|
Ok what I was doing was a little different. I was resizing the panel each time the splitter is moved. So the two panels were resizing each time the MouseMove of the splitter is called. The problem with this the panel resizing is not done smoothly as required.
I tried making a few changes to the code now. Relocating the splitter location in mouse move and relocating and resizing the panels in the mouseup.
Here is what I did. Please let me know if I can improve this anymore and allow a cleaner dispaly.
public class NoDockSplitter : Label
{
public NoDockSplitter()
{
// set styles to prevent flickering
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyles();
}
protected void SetStyles()
{
this.BorderStyle = BorderStyle.None;
this.Text = "|";
this.TextAlign = ContentAlignment.MiddleCenter;
}
protected Control _leftSideControl;
protected Control _rightSideControl;
public Control LeftSideControl
{
get
{
return _leftSideControl;
}
set
{
_leftSideControl =value;
SetControlSize(_leftSideControl);
}
}
public Control RightSideControl
{
get
{
return _rightSideControl;
}
set
{
_rightSideControl =value;
SetControlSize( _rightSideControl);
}
}
protected bool _mouseDown = false;
protected bool _sizeSet = false;
protected int _leftSideControlWidth = 0;
protected int _rightSideControlWidth = 0;
protected int _rightSideControlXPos = 0;
protected int _splitterStartXPos = 0;
protected bool _widthSet = false;
protected int _diff = 0;
protected int _startXPos = 0;
protected void SetControlSize(Control c)
{
if(! _sizeSet )
{
this.Size = new Size( 4, c.Height);
_sizeSet = true;
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter (e);
this.Cursor = Cursors.VSplit;
if( !_widthSet)
{
_leftSideControlWidth = _leftSideControl.Width;
_rightSideControlWidth = _rightSideControl.Width;
_rightSideControlXPos = _rightSideControl.Location.X;
_splitterStartXPos = this.Location.X;
_widthSet = true;
}
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave (e);
this.Cursor = Cursors.Default;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown (e);
_mouseDown = true;
_diff = 0;
_startXPos = e.X;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
if( _mouseDown)
{
_diff = _startXPos - e.X;
this.Location = new Point(_splitterStartXPos - _diff, this.Location.Y);
this.Parent.Refresh();
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp (e);
if( _mouseDown)
{
_diff = _startXPos - e.X;
this.Location = new Point(_splitterStartXPos - _diff, this.Location.Y);
_leftSideControl.Width = _leftSideControlWidth - _diff;
_rightSideControl.Width = _rightSideControlWidth + _diff;
_rightSideControl.Location = new Point( _rightSideControlXPos - _diff, _rightSideControl.Location.Y);
this.Parent.Refresh();
}
_mouseDown = false;
}
}
|
|
|
|
|
My additional need was to have a splitter between controls that are not docked at all. So I need a control that behaves like a splitter but for undocked controls.
Thanks,
VPMahank
|
|
|
|
|
how can i scroll panels scroollbars automaticaly
|
|
|
|
|
panel M = new panel();
M.AutoScroll = true? perhaps?
|
|
|
|
|
No i mean,
I have a panel, at run time i add pictureBoxes when user clicked a button.
And i want to show last added picture at the end of panel as EnsureVisible Property of ListView.
|
|
|
|
|
Hi!
Is it possible to Embed and Run a VB6 Exe in .NET Windows Application
If Yes, then how to how to communicate with that Exe (set or get variables), call functions, etc.
If No, then please tell me any other way to communicate that exe
Actually I am trying to develop an application in .NET (C# Or VB .NET) and this application does not support controls used in VB6 Exe
The VB6 Exe connects to the database, How do i send the connection string to that exe from .NET application
Is there any way other than "CommandLine arguments"?
Thank you
Gulfraz Khan
|
|
|
|
|
There is no way to embed a VB6 app inside a .NET app and expect it to run. It must be a seperate file.
Communication is going to be a huge PITA. You cannot call its functions or anything else, unless the VB6 app exports them through COM. A normal VB6 app cannot do this unless it's written as an ActiveX server.
As for the controls that work in VB6 and won't work in C#, I doubt it. I haven't come acrossed a control that didn't work in the .NET world, but did in VB6. I have, however, come acrossed some badly written controls that I didn't even bother with in the conversion to .NET. I either got an updated control or just wrote an equivalent control myself and replaced it.
Your best solution is to scrap the VB6 app entirely and rewrite in C#. Why have 2 different runtimes loaded, VB6 Runtime and the .NET Framework, for your app to work?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello everybody.
I've just started with C# programming and I'm new here. I've only studied C# for half a term so you can say i can't so much about programming. I love to program, but anyway to my question.
I've just done a small game and I would like to have a highscore table that is saved everytime I close the game.
everyone here seems to be better than me so this is propably kind of easy for you guys ha?
Tutorials or just type the code here maybe?
any help is appreciated.
thank you.
Simon an amateur in c# programming.
|
|
|
|