|
I think is a good idea
But very complex to maintain
We are all use of this kind of interface
The IDE work exactly as I want:
Multiple pages, im my case Forms
The tree view is the solution explorer.
How could be this so dificult to replicate.
Cristian
|
|
|
|
|
If you are absolutely determined to do 'Form Docking', it can be done. But not in pure c#. A great deal of P/Invoke is required, to get this functionality.
Take a look at this[^] for examples.
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.”
|
|
|
|
|
I take back some of my last post.
I have just read Eddy Vluggens response.
This definitely CAN be done in pure c#.
Very slight modification to his code
private void btnForm_Click(object sender, EventArgs e)
{
Form newForm = new Form();
newForm.TopLevel = false;
newForm.Parent = this;
newForm.Visible = true;
newForm.Location = new Point(10, 10);
newForm.Size = new Size(this.ClientSize.Width - 20, this.ClientSize.Height - this.panel1.Height - 20);
newForm.BackColor = Color.Bisque;
newForm.FormBorderStyle = FormBorderStyle.None;
this.Controls.Add(newForm);
}
getting rid of the border, to save you having to look it up if you weren't aware of it already.
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 Christian,
I am having exactly the same problem.
I use a SplitContainer and and have placed a TreeView control inside. In the right side of the split container, one of five different Forms shall be loaded, depending on what's selected in the TreeView. Up to now, I unfortunately have not found a solution, but I'm new to C#, so this does not mean anything
"SubForms" even work in LabVIEW, so I would be very amazed, if C# would be unable to do the same...
Peter
|
|
|
|
|
I have seen this in 3P Component, I think it was .Net Bar
But this is out of my budget, So I'm trying to develop a solution with the component that come with C#.
If I find something I let you know.
Cristian
|
|
|
|
|
Ok, that sounds fine. Thank you!
Peter
|
|
|
|
|
A form inside a form;
Form newForm = new Form();
newForm.TopLevel = false;
newForm.Parent = this;
newForm.Visible = true;
newForm.Location = new Point(10, 10);
this.Controls.Add(newForm);
Is this what you're after?
Happy Programming
I are troll
|
|
|
|
|
Perhaps you could use the NativeWindow class, passing a CreateParams structure with its Parent property set to the Handle property of the right handle Panel. Then, display the form and use the SetParent PInvoke call to make it a child window of the parent
Pseudocode:
NativeWindow wnd = new NativeWindow(new CreateParams()
{
Parent = rightHandPanel.Handle,
Height = rightHandPanel.Height,
Width = rightHandPanel.Width,
X = Y = 0
}
Form display = formYouWantToDisplay;
wnd.CreateHandle();
display.Show(wnd);
This would require quite a bit of research to work properly I think. Are you sure you don't just want to have an MDI parent, and dock a panel containing a treeview to the left hand side?
modified on Sunday, March 1, 2009 1:54 PM
|
|
|
|
|
If you use MDI, you can't exactly control where the MdiClient (which is where MDI children are located) window goes.
However, I would try this (I once tried something similar and it worked):
1. Create your main form
2. Set its IsMdiContainer property to true
3. Add a panel and dock it to the left of your main form.
[EDIT: If you want a splitter, add it here and also dock it to the left. But don't add a SplitContainer , but an original Splitter[^] control.]
4. Add the TreeView and whatever else inside that panel
When you create MDI children, they will be located inside the MDI client area, which will be to the right of your tree view.
I hope this helps
|
|
|
|
|
Hi evirione
For any one interest in this
Here I publish my solution
Object in Form1
splitContainer1
tabControl1 (in the right panel of the splitContainer1)
The tabControl does not have any page on design.
The left panel I intent to put a treeView, but for this code, there is a button
button1 (in the left panel of the splitContainer1)
this is the code for the button click event
private void button1_Click(object sender, EventArgs e)
{
TabPage newTabPage = new TabPage("Form " + tabControl1.TabPages.Count);
newTabPage.Size = new Size(tabControl1.Width, tabControl1.Height);
Form2 newForm = new Form2();
newForm.TopLevel = false;
newForm.Parent = this;
newForm.Visible = true;
newForm.Location = newTabPage.Location;
newForm.Location = new Point(3, 3);
newForm.Size = new Size(newTabPage.Width - 3, newTabPage.Height - 3);
newForm.FormBorderStyle = FormBorderStyle.None;
newTabPage.Controls.Add(newForm);
tabControl1.TabPages.Add(newTabPage);
}
Becaus Microsoft does not provide the Tab control we all use in the IDE, that allow to close a tabpage with an X in the upper right corner, I have no alternative and just use a normal tabControl
Now, in order to destroy the tabpage when closing the form created on each page.
In Form2 I add a button, and the followin code.( this close the form and destroy the tab page.
private void button1_Click(object sender, EventArgs e)
{
TabPage tab = this.Parent as TabPage;
TabControl tabControl = tab.Parent as TabControl;
tabControl.TabPages.Remove(tab);
this.Dispose();
}
Hope this help
Cristian Conrads
modified on Monday, March 2, 2009 7:05 PM
|
|
|
|
|
I want to display a calender on desktop [right side] if any one can help me helping link
Please keep following points in mind
- application will be running in background. [at startup]
- icon will be in Tray no tab in Task bar. when double clicked then in Task Bar.
Thanks
|
|
|
|
|
To make your application run when Windows starts, put it into the Startup folder. I think there are registry keys you can add it to. To make the tray icon, use the NotifyIcon component, and simply show the form with the calendar upon the double click of the aforementioned component. You can actually find a calendar-like component in the .Net Framework - I think it's something like DateTimePicker. Inherit from that, link it to a collection of dates, and you have your calendar. To make the form display on the right hand side of the desktop, set the Dock property of the form to Right
|
|
|
|
|
Thanks For Giving Idea
But i am talking to put calender on desktop not on the form's right. On desktop where icons will be on left side and my calender on right side
hope u understand what i want.
|
|
|
|
|
I see. You could theoretically put some code in the Resize event handler to adjust the size and location of the form. Use these equations:
Form.X = Screen.Width - Form.Width
Form.Y = 0
Form.Height = Screen.Height
Form.Width can be anything you want it to be. This will look best if you set the BorderStyle to None
|
|
|
|
|
Nice Idea to calculate the Location on desktop.
But i want to bound the calender application object added to Windows Desktop Object in such a way that it behave like icons on desktop. so that when all applications in Taskbar are minimized my application still will be visible on desktop
Basic thing i want is access to desktop and put my calender object into that.
|
|
|
|
|
Then what you may want is to create a gadget for the Sidebar. This will limit your options to Vista. Alternatively, you could look into shell integration (perhaps a knowledge of COM would help you here) or the ShowInTaskbar property of a form
|
|
|
|
|
|
I want to save changes in my C# form. So I tried this. There are 3 buttons on my form but the code saves only button3's location. What should I do? Please help me!
foreach (Button a in Form1.ActiveForm.Controls)
{
Properties.Settings.Default.SavedSetting3 = a.Location;
}
Properties.Settings.Default.Save();
Thanks in advance
|
|
|
|
|
You can save in one setting entry only one value. From what you are doing, you are trying to save 3 different locations to one setting entry(SavedSetting3) which is wrong. In each loop execution you are overwriting the last set value and hence, the value which is last written (button3 I guess) is the one which is saved. You will need to create 3 different setting's entry to save each of the buttons location.
|
|
|
|
|
Thank you. What if I don't know how many buttons or controls exist? How can I create a setting for each control? I'm working on a programme that users can add controls at run time.
|
|
|
|
|
You can have these settings saved for you automatically. Just have a google for 'App.Config' or 'Saving Form Location' and read up about it.
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.”
|
|
|
|
|
Hi I am trying to handle a file not found exception by creating the specified text file if it does not exists.
void RetrieveData()
{
if(File.Exists("books.txt") == false) // if file doesnt exists
{
File.Create("books.txt"); // create the file
}
//Create a stream reader object to read from "books.txt"
StreamReader DataReader = new StreamReader("books.txt");
}
I did a test run and remove the books.txt file from the current working directory on purpose and when i start debugging all I get is this exception :
The process cannot access the file 'C:\Documents and Settings\Administrator\My Documents\NYP Work\C#\MiniProject 2009\PhotoAlbum_V2\bin\Debug\books.txt' because it is being used by another process.
Any suggested solutions ?
|
|
|
|
|
Your problem lies with the File.Create method. It returns a FileStream instantiation. Until you close the FileStream, you cannot read the file without requesting different access to it. Try something like this
void RetrieveData()
{
Stream bookStream = new FileStream("books.txt", FileMode.OpenOrCreate);
using(StreamReader booksReader = new StreamReader(bookStream))
{
}
}
The trick here is creating a new FileStream with FileMode.OpenOrCreate. If the file exists, it is opened; if it doesn't exist, it is created and then opened. If you want to check whether the file is empty (it's pointless reading from an empty file), check whether bookStream.Length is equal to zero. This will also tell you if the file is newly created because the newly created file will be empty
|
|
|
|
|
thanks it worked well that way.
|
|
|
|
|
How do we build a network ..
|
|
|
|