|
Arun Bhalla wrote:
Is the part on the right of Windows Explorer exactly a ListView, or is it something derived from ListView?
It is a ListView, but I would assume it makes use of every single customization you could use
Arun Bhalla wrote:
Does ListView inherently support the desktop-like qualities in Icon view where you can drag the icons around arbitrarily and make a cluttered mess?
The underlying Win32 control does support it, but it doesn't look like the .NET wrapper of the control does. Of course, if you can do it in Win32 you can do it in .NET by using P/Invoke to call the system APIs. You just have a ton of work cut out for you if you are recreating all aspects of Explorer.
Arun Bhalla wrote:
what is the best way to make a DesktopPanel-like control in C#. Something derived from Panel, ListView, or something entirely different?
I'm not sure what type of program this would be mimicing...something like the Windows Taskbar (a screen wide/high form which stays docked to a side of the screen)? I'm pretty sure there is an article here on CP which makes something like this.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
James T. Johnson wrote:
un Bhalla wrote:
what is the best way to make a DesktopPanel-like control in C#. Something derived from Panel, ListView, or something entirely different?
I'm not sure what type of program this would be mimicing...something like the Windows Taskbar (a screen wide/high form which stays docked to a side of the screen)? I'm pretty sure there is an article here on CP which makes something like this.
Well, I think I was misleading with "DesktopPanel-like." I actually have in mind some control like (Java) Swing's JDesktopPane and an associated desktop manager. Ideally this control would manage scrolling, etc. I'm under the impression that a Panel (or ScrollablePanel) is my best bet, but I'm checking to see if there are other handy possibilities.
If one were to create a control in an application that mimics the system desktop or the iconic folder view of an Explorer, what would be the best route to take?
|
|
|
|
|
You may want to check out ActiveWare's layout manager (www.activewaresolutions.com). It will help manage your controls in a given area and automatically take care of the scrolling as well. I used it for a slightly different purpose, but it sounds like it may work here for you as well.
|
|
|
|
|
As James pointed out, the different views that can be created are just multiple controls in a single form.
If you have a more complex process (a window with data and a properties box) similar to VS, then you get into an MDI parent and child management scenario.
This requires that you first have a main form which is your container. You can use the Magic Library (www.dotnetmagic.com) to create a docked form which can act as a sliding property box. That property box is just a form with various list controls and an exposed public property so that you can pass what it should display properties on.
You have to decide how the children are opened....a selector window like the Solution Explorer or a menu option. The act of opening is just creating a new instance, setting its' MDIParent property to your main form, and showing it. The child forms are developed as normal stand-alone forms.
I also had a need for a child form to notify the parent form that a user performed a particular action. So I created an event and delegate in my child form and then delegated the event to a method in my parent form. My children just have to raise the event to get the logic in the parent fired off.
Now, this is definitely more complex -- and James' answer sounds more like what you're looking for. But this is the other way of managing a more complex type of display like Visual Studio.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hello theRealCondor, James,
James thanks for your suggestions, I had pretty much worked on the principle of controls on the page layed out as you mentioned. I really wanted to take it to the next level.
theRealCondor, I think you hit it on the head. The sample picture at "www.dotnetmagic.com" of multiple windows and docking were exactly what what I wanted to achieve.
follow the link http://www.dotnetmagic.com/images3/features2.gif[^]
I would like to know more about this:
theRealCondor wrote:
I also had a need for a child form to notify the parent form that a user performed a particular action. So I created an event and delegate in my child form and then delegated the event to a method in my parent form. My children just have to raise the event to get the logic in the parent fired off.
It appears to me that to make multi windows play well I need to see how this works together.
Well thanks again for a place to start. Any additional help with this would be much appreciated.
Regards,
uBoat42
|
|
|
|
|
Situation:
I had an MDI parent. I added another form which is my 'launcher' and that is docked in the Magic Docking Control. In my parent -- at form load time -- it was a simple matter of a few simple steps:
Instantiate an instance of the dockManger
Instantiate an instance of the launcher (I pass the handle of
the parent to the launcher in the Constructor logic)
Add the launcher instance to the dockManager
Voila -- it works just grand and is very simple to implement
<br />
manager = new DockingManager(this, VisualStyle.IDE);<br />
Content ef = manager.Contents.Add(new editorForm<br />
(this, userChoices, desiredWeb), "Navigation Flows");<br />
ef.DisplaySize = new Size(192,464);<br />
ef.FloatingSize = new Size(192, 464);<br />
ef.AutoHideSize = new Size(192, 464);<br />
this.menuItem1.Enabled = true;<br />
manager.AddContentWithState(ef, State.DockLeft);<br />
Setting the sizes shown above is pixel tweaking to have the window open up as far as I wanted it to be displayed. (width is main value the manager is concerened with)
Next issue:
Each child constructs a navigation view. I was asked to change colors whenever one page in the view is replicated across children. This meant I had to wait until the child was fully implemented to handle the color change.
<br />
editView newView = new editView<br />
(StartingPageName, tcaAccessor, holdWebCollection, holdWebname);<br />
newView.MdiParent = thisParent;<br />
newView.Text = selectedObject.Text;<br />
main ParentForm = thisParent as main;<br />
newView.CompletedLoadEvent += new editView.CompletedLoadEventHandler(ParentForm.mdiParent_childLoadComplete);<br />
newView.Show();<br />
I pass the objects the child needs. I establish MDIParent to my parent form in the new child, and I establish the evenhandler in my parent form as well. Then I launch the child with the Show();
So in my base child form, I define the event:
<br />
public delegate void CompletedLoadEventHandler<br />
(object sender, string childName);<br />
public event CompletedLoadEventHandler CompletedLoadEvent;<br />
Then at the end of the load process I raise the event:
<br />
if (CompletedLoadEvent != null)<br />
CompletedLoadEvent(this, this.Text);<br />
You could code a number of custom events to comunicate back to the parent. I found that I had to do a custom event to guarantee that some accidental firing of an already-existing event did no occur.
If you happen to have the launcher as a menu item within the parent it is even easier since you do not have to hold reference to your parent inside the launcher. In setting up the launcher inside the manager --- creating the new launcher and passing (this) as a parameter which my launcher saves as a variable thisParent inside itself makes the launcher properly define the parent in each child.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hello theRealCondor,
I managed to get so far with the frame of my mdi app using the magic control you pointed me to.
/* excuse's
Bear with me if you can, it's been a while between writing winforms apps. I've been doing a lot with web based stuff, so I'm trying to get my head around it again...
*/
I have 3 forms in my mdi app, frmMain (mdiparent), frmOutLookBar (_manager.DockLeft) and frmHome (should fill everything except the area of frmOutLookBar).
The idea is to have an outlook style layout. So I have the frmMain that loads the menu (frmOutLookBar), I dock this to the left. Here's where I've run into a wall. I can't figure out how to get the frmHome to fill the area to the right of the frmOutLookBar.
Code: 1st attempt;
<br />
_dockingManager = new DockingManager(this, VisualStyle.IDE);<br />
<br />
Content LeftWindow = _dockingManager.Contents.Add(new frmOutLookBar(), "Control Menu");<br />
<br />
_dockingManager.AddContentWithState(LeftWindow, State.DockLeft);<br />
_dockingManager.ShowContent(LeftWindow);<br />
This gave me the stand alone left docking as hoped. I also tried to dock the frmHome to the right.
Code: 2nd attempt;
<br />
_dockingManager = new DockingManager(this, VisualStyle.IDE);<br />
<br />
Content LeftWindow = _dockingManager.Contents.Add(new frmOutLookBar(), "Control Menu");<br />
<br />
_dockingManager.AddContentWithState(LeftWindow, State.DockLeft);<br />
_dockingManager.ShowContent(LeftWindow);<br />
<br />
Content RightWindow = _dockingManager.Contents.Add(new frmHome(), "Control Menu");<br />
<br />
_dockingManager.AddContentWithState(RightWindow, State.DockRight);<br />
_dockingManager.ShowContent(RightWindow);<br />
This gave me two docked windows, a left docked window, a gap and a right docked window??
Any help with getting frmHome on the right side as a filler would be great!
Definitely getting closer to what I'm after,
John
|
|
|
|
|
Sorry it took too long to reply....my father died last weekend.
Do this:
Your work with docking the control on the left is fine.
Make certain that your frmHome Dock = Fill.
frmHome fillscrn = new frmHome();
fillscrn.MDIParent = this;
fillscrn.Show();
Now what this gives you is your Outlook style on the left which slides in and out. A second window on the right that fills the area. It's code functions independant which is fine as long as your main form has no need for catching events from the child.
If you want a TRUE outlook experience, then you can take an easier approach:
mainForm is your only form.
Drop in a panel and create your OutlookPanel inside this panel (Dock=Left).
Drop a slider in the form.
Drop another panel in the form Dock=Fill
Populate the panel with all your data.
This gives you a true Outlook experience but it is a fairly static form. With the MDIChild approach you gain a benefit if you are showing a different form for different users -- since you can encapsulate your logic within each individual form.
Another benefit of the MDIChild approach is that the panel (your right-filled form) is coded as a stand-alone form which contains all of its' logic in one place and is not scattered among the icon bar logic and other form management tasks.
If the child form needs to be notified that an icon was clicked in the Outlook bar, then you expose those via events (full detail is in the MSDN help files within VS)
Hope this moves you forward.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
<input id="MyFile" type="file" runat="server">
This control produces a textbox w/browse button. I've tried in the server side to set
this.MyFile.Value = MyFile.PostedFile.FileName;
in order to repopulate the textbox part when returning a message such as "file successfully uploaded". It's not taking it.
Any ideas?
|
|
|
|
|
Your browswer shouldn't let you specify a file in HTML or javascript...doing so would be very insecure. Imagine someone setting the value of the textbox to the location of a well known file, such as the MS Money 2002 data file, then using JavaScript to submit the form
Even if you skipped the submittal via javascript you could use some CSS/HTML trickery to hide the file selection box, keeping your default value of the well known file.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Hi,
In my WinForm App, I have to show another form2. but I do have to know if the user click on OK or Cancel. therefore I assigned DialogResult property of OK and Cancel button on Form2 to OK and Cancel, respectively. It works fine and I can use Dialogresult to figure out whether the OK or Cancel button is clicked to close the Form2.
The problem comes in when I add a errorProvider1 to form2, I use it to make sure a couple of textBoxes are not empty and then SetError on ErrorProvider. Because the OK button has DialogResult.OK property set, the dialog closes before I got chance to view the error.
Is there anyway to prevent the dialog form close if I have any errors. It is so easy to do in old MFC days. .
Dion
|
|
|
|
|
Why not just catch the yourbutton.OnClick event?
private void button1_Click(object sender, System.EventArgs e)
{
if(textBox1.Text.Length == 0 || textBox2.Text.Length == 0)//etc.
{
//Your error handling code
MessageBox.Show("Please, enter some text");
return;
}
this.Close();
}
Hope being helpful
Cheers,
Gogou
GAtanasov
|
|
|
|
|
Thanks for your help.
I definitely can do my validation on btnOK_click event, but how do I know from my main form whether an user clicked on OK button or Cancel button if I do not set the DialogResult property. But if I set DialogResult property, the OK button closes the form before I can see the validation errors.
I'd like to achieve BOTH:
1. TextBox Validation when OK is clicked, if there is error, do not close the form.
2. If there is no error, the Form2 is closed. From the caller, I want to know whether an user click on OK or Cancel.
How do I achieve this?
Dion
|
|
|
|
|
DionChen wrote:
TextBox Validation when OK is clicked
Handle the Validating and Validated events on your textboxes. If you look up the Control.Validating event in MSDN you'll see an example using the events with the ErrorProvider class.
Just remember to set the CausesValidation property to false on at least the cancel button, or you can't click it without providing valid data.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
You can achieve this by setting the form2 DialogResult to None. EX:
if (txtName == "")
{
//Show error message
this.DialogResult = DialogResult.None
}
No time to breathe
|
|
|
|
|
In the parent form:
<br />
GetMyData diagInfo = new GetMyData();<br />
if (diagInfo.ShowDialog() == DialogResult.Cancel)<br />
{<br />
cancel logic<br />
}<br />
else<br />
{<br />
doit<br />
}<br />
The dialog form:
<br />
public GeMyData<br />
{<br />
}<br />
public string GiveMeInfoOne<br />
{<br />
get<br />
{ return info1.Text; }<br />
}<br />
public string GiveMeInfoTwo<br />
{<br />
get<br />
{ return info2.Text; }<br />
}<br />
private void button1_Click(Object sender, EventArgs e)<br />
{<br />
if (info1.Text == "" or info2.Text == "")<br />
{<br />
MessageBox.Show("You really must enter data in my text boxes or I<br />
will never go away and I will haunt you the rest of your days");<br />
}<br />
else<br />
{<br />
this.DialogResult = DialogResult.OK;<br />
this.Close();<br />
return;<br />
}<br />
}<br />
Voila -- your dialog never closes until you have a good bit of data in each box and you actually execute a return.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Does anyone know how i can change the color of the background of a checkbox in a tree view? The treeview is in a non-standard color and the white of the checkbox doesnt look right at all.
i read about the tri-state checkbox image but i dont think i want to take it that far at this stage.
|
|
|
|
|
Hi,
i would like to let the user edit his data in a datagrid. The datagrid is bound to a dataset. If the user close the form i would like to know:
- are there changes?
- would he like to accept or reject changes?
<p>But this do not work, cause it seems that the datagrid flush the data on dispose to the dataset, could that be ? cause HasChanges() returns false, all the time, even if i've got changes made to the Datagrid/dataset.
Is there a way to flush the changes made in datagrid to dataset, then check it, ask user and accept or reject changes ?
.:Greets from Jerry Maguire:.</p>
|
|
|
|
|
Override on closing rather
This what I did (in fact just yesterday):
<font size=2 face="Courier New"><font color="#0000FF">protected </font><font color="#000000">override </font><font color="#0000FF">void </font><font color="#000000">OnClosing</font>(<font color="#000000">CancelEventArgs e</font>)
{
<font color="#000000">DataSet ds </font>= <font color="#000000">dataSet1</font>.<font color="#000000">GetChanges</font>();
<font color="#0000FF">if </font>(<font color="#000000">ds </font>!= <font color="#000000">null</font>)
{
<font color="#000000">DialogResult result </font>= <font color="#000000">MessageBox</font>.<font color="#000000">Show</font>(<font color="#0000FF">this</font>,
<font color="#FFFFFF"> </font><font color="#FF8000">"Would you like to save " </font>+ <font color="#000000">datafile </font>+ <font color="#FF8000">" ?"</font>, <font color="#FF8000">"Confirm save file..."</font>,
<font color="#000000">MessageBoxButtons</font>.<font color="#000000">YesNoCancel</font>, <font color="#000000">MessageBoxIcon</font>.<font color="#000000">Question</font>);
<font color="#0000FF">switch </font>(<font color="#000000">result</font>)
{
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Yes</font>:
<font color="#000000">SaveXml</font>(<font color="#000000">datafile</font>);
<font color="#0000FF">break</font>;
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">No</font>:
<font color="#0000FF">break</font>;
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Cancel</font>:
<font color="#000000">e</font>.<font color="#000000">Cancel </font>= <font color="#0000FF">true</font>;
<font color="#0000FF">break</font>;
}
}
<font color="#000000">base</font>.<font color="#000000">OnClosing</font>(<font color="#000000">e</font>);
}
</font> SaveXml() is just a method I have to save the XML and datafile is a string that is the file's full path and name.
Hope this helps
[edit] I just realize its almost the same, except perhaps that you are using the event rather than overriding, and that you call GetChanges(). Never did try that How do you persist (load/save) the dataset anyways? Are you not calling AcceptChanges somewher in between, that would cause it to return false more than often. I call AcceptChanges only one after I have read the XML from a file.[/edit]
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi,
thank you, but it looks more like a workaround ,)
ok, i have to call AcceptChanges after i load the dataset from disk. These resets the interal dirty state to false. Now the user edit some values in the datagrid (HasChanges() should now return true), he close the form, OnClosing i ask him to save (checked by HasChanges), he AcceptChanges or reject changes ?
that's the way i would like to get this done. What i'm doing wrong ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (dataSet11.HasChanges())
{
switch ( MessageBox.Show("Do you wish to save your changes made for bla bla?" , "Save", MessageBoxButtons.YesNoCancel))
{
case DialogResult.Yes:
this.sqlDataAdapter1.Update(this.dataSet11);
break;
case DialogResult.No:
break;
case DialogResult.Cancel:
e.Cancel = true;
break;
}
}
}
|
|
|
|
|
Hi,
i do not use a SqlDataAdapter, the dataset is a class member. If i store the dataset to disk or to SqlDatabase, it's quite easy, cause i've i do not call a Save method, nothing happens, being updated.
Otherwise if the dataset is in a class, and the class.DataSet is bound to a datagrid, it's harder
.:Greets from Jerry Maguire:.
|
|
|
|
|
I have an XPathNodeIterator and I've been crawling through an dom tree reading in information. What I want to do is, given a node or attribute, I want an xpath expression that refers to that node.
So in other words, the opposite of XPathNavigator.Evaluate(). I want a method that takes a node and returns a string that says "/html/body/table[2]/tr[4]/td"
Is there anything built in like that? making it myself would be a pain.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Not that I know of. You can iterate backwards through the document and build
/html/body/table/tr/td
but to get the index, you'd have to iterate through the children at the same level, and try to figure out which was yours.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hi, Coders
I have the following problem:
I am overriding a TabControl class in order to make his appearance better.
It worked just fine till I decided to implement the scrolling of the tabs - I can't get rid of the scrolling buttons windows is displaying. I tried overriding almost every virtual method and adding " Invalidate() " to it, but the scrolling buttons don't care - they still are visible
Any sugestion of how I can remove them?
Cheers,
Gogou
GAtanasov
|
|
|
|
|