|
britishcolumbia wrote: For Each item As String In "C:/Program Files/Testfile.txt"
You really need to pickup a beginners book on VB.NET and work through it. Just specifying a string in a For Each doesn't automatically assume that string is a file path and open it for reading.
britishcolumbia wrote: Im creating a web browser for a friend
So, why doesn't your friend get a hold of IE8 or FireFox and have a working web browser now, instead of waiting for a couple of months for you to figure out how to write one?? After all, your obviously just wrapping the built-in WebBrowser component, which is just IE anyway.
Seriously, your code is so bad that I don't consider it fixable. I'd scrap it and rewrite it from scratch, using XML to store the Favorites instead of a straight text file.
|
|
|
|
|
Please keep your comments to your self if you don't plan to help anyone.
Everyone starts somwhere, I start here.
If you’re the Microsoft MVP, you most likley know how to fix this. If you would like, without criticizing me, please help me out. If not, good day to you.
|
|
|
|
|
Do you really expect people to spend time and help you with your attitude?
Be smart and recognize good advice when it is offered.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Allright, well I'm going to close this post, Im just used to other forums where that would have been considered "Bad help" but I'm new here, so I suppose things work a little differently.
I guess I took the previous post the wrong way, I thought that saying that the code was so bad that I should just re-write it, and then saying that the whole project was nutty, or worthless as I took it. I don't really see that too much outside of YouTube commenting, and thought it was a bit rude.
I was just looking for a bit of advice. That’s for whatever you gave me, even if I didn’t see it.
|
|
|
|
|
I'd agree with you actually, he was a bit rude. But he is also right! You do need to learn the basic concepts, and while you're welcome to make your own IE-based web browser (the web browser component is full of IE code as far as I understand) it probably isn't the best way to learn.
If you really want advice, as opposed to code that loads/saves bookmarks, then none can be better than getting a good introductory programming book. There's no shame in being a beginner, but it's smart to realize that you are one and work from that assumption.
Personally I'd advice you to go with C# instead of VB.NET though. Let me be clear about this right away: C# and VB.NET will both allow you to do the same, and you'll achieve the same performance (or lack thereof, depending on your code) no matter which one you use. However, a lot of VB.NET coders have come to the .net platform from lesser programming tools (in my opinion) such as VB6, Access, and probably a few people who have just written a few macros in Excel (VBA), while a lot of C/C++/java coders have picked up C#. This might upset some people, but in my opinion there is little doubt that the C# community is of higher average quality than the VB.NET one. There are awful and great programmers in both camps of course, but if I were you I'd choose to associate with the C# lot.
VB.NET on the other hand might be preferable in some ways. It has optional parameters, which is in fact useful if you do Microsoft Office programming (lots of methods with 30 parameters - it's the one thing I will use VB.NET for if free to choose). And the Visual Studio tools are sometimes more refined for VB, presumably because MS feels it's necessary to nanny VB.NET users a bit more. For example, the code snippets that ship with VS include lots of VB stuff and little C# stuff.
My two cents.
|
|
|
|
|
britishcolumbia wrote: you most likley know how to fix this
Yes, and I already told you how. I would scrap the whole thing and start over with an XML storage format.
Seriously, even the basics of VB.NET is beyond you right now. How successful do you think your going to be if you don't understand the simple concepts of loops and enumerations?? Get a book on VB.NET and start teaching yourself the basics. I'm not trying to insult you, but just trying to prevent frustration and a lot of wasted time posting question on forums and waiting hours/days for answers to questions that you wouldn't even have to ask in the first place if you understood the basics of how VB.NET works and how it relates to the .NET Framework.
britishcolumbia wrote: If you would like, without criticizing me, please help me out.
Excuse me if I questiond the whole point of writing your "own" web browser for your friend. The whole concept of him/her waiting for you to write a browser is a bit nutty.
|
|
|
|
|
Hello Friends..
I want to call Shell from my vb.net windows application and run the command.
I have tried like
"Process.Start("cmd.exe", "cd\")"
But it just open command prompt.Does not run the command which passed by argument. That is "Cd\".
How can i do that...????
Thanks in advance.
|
|
|
|
|
|
Create a bacth file of ur command and execute it.
|
|
|
|
|
I cannot run any dotnet executable if the path including the name of the exe exceeds 128 characters.
The executable does appear for a split second and disappears immediately.
There is nothing in the event log.
I'm running Windows XP SP3, and .NET framework 2 SP1.
Any help is appreciated.
Thank you,
Michel
|
|
|
|
|
msmits wrote: The executable does appear for a split second and disappears immediately.
In that case, you've got some debugging to do. Since the code runs and shows a window, albeit briefly, it means your code IS running. So, the problem would have to be in your code somewhere. Is your code using files somewhere?? Is it handling the path names with spaces properly??
|
|
|
|
|
Hi Dave,
This problem happens with ANY exe, mine or anyone else's.
I've also created a new windows forms application (without code) and it behaves the same.
I've also debugged an application, it steps through the code and exits after the last debuggable statement (i.e. when it enters the event handling phase).
I've done this on VS2005 and VS2008.
Just to make it stranger, if I start the application rapidly many times in a row, *some* instances actually stay alive.
Cheers,
Michel
|
|
|
|
|
Sorry I made a small mistake in last post, with "any exe" I mean "any .NET exe".
Cheers,
Michel
|
|
|
|
|
msmits wrote: his problem happens with ANY exe, mine or anyone else's.
Well, you didn't say that in your original post, so how were we supposed to know??
msmits wrote: Just to make it stranger, if I start the application rapidly many times in a row, *some* instances actually stay alive.
In that case, make sure your machine hasn't had a virus introduced, then uninstall and reinstall the .NET Frameworks.
Oops. I just saw your last post. Glad you got it fixed!
|
|
|
|
|
When the application exits in Visual Studio in the debug window I see the message:
The program '[4756] MyTestApp.vshost.exe: Managed' has exited with code
-1073741819 (0xc0000005).
After searching for the error code on search.microsoft.com I found there are quite some people with the same problem. There was one solution listed and it works for me.
The problem is caused by the Kensington Mouseworks software that I have installed. It is very strange indeed but after uninstalling it the problem disappeared.
Cheers,
Michel
|
|
|
|
|
Hi all,
I have a requirement like.. i want develop a tool which will create and add a class library project to a given solution. and also i am able to add a class file to the project with a given name.
Please suggest me how can i do this..
Thanks in Advance.
|
|
|
|
|
First I'd try it manually with Notepad. Once you see the structure of the solution you should be able to write something that uses a System.Xml.XmlDocument to do it.
|
|
|
|
|
Hi Guys,
I've got an app composed of a moderately complicated control hierachy. I have a situation where on selecting a different node in a tree view, i'd like to focus on a seperate control and have that focus bubble up to the primary text box so that it can be edited straight away, however the OnGotFocus method in my custom control never gets called after control.Focus(), so can't be bubbled up the object tree.
Any ideas how to get around this?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Tristan Rhodes wrote: I have a situation where on selecting a different node in a tree view, i'd like to focus on a seperate control and have that focus bubble up to the primary text box so that it can be edited straight away
What is the purpose of the middle control getting involved? Sounds like you are over complicating things.
Tristan Rhodes wrote: I've got an app composed of a moderately complicated control hierachy
I would look into simplifying it. One example would be the Mediator pattern[^]
If you are not familiar with patterns or even this one in particular, don't get bogged down in the details. Look at the description of the pattern, the problem it solves and the basic idea of how. Even if you roll your own and it doesn't match the pattern exactly, it will still be far superior to the tightly coupled approach you seem to be currently engaged in.
|
|
|
|
|
I've got a Treeview for item selection / association and another control for editing / validating the selected item. These form a composite control responsible for managing the Items collection. There are a number of similar style controls (View / Editor combo) with responsibilities for different parts of the application data beside items. These all sit on an observable model which can be modified and kept in sync with the various views and handle the Undo/Redo commands.
I'm trying to get the manager control to handle the Selected event in the tree view / list and pass the focus to the editor control, which in turn would focus on it's main field so the user can edit and tab through the various controls without having to click on it first.
I'm hoping to make this the default behavior for each view, but for some reason the Focus event gets eaten by the Custom control.
EDIT: Ok - so it IS shifting focus, but it's not raising an event or the OnFocus method, and i have no control over what it selects. I thought it was tab index, but it doesn't do anything that i can see.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
modified on Tuesday, April 7, 2009 8:05 AM
|
|
|
|
|
Ok, now I recognize that I can't understand the design as you are stating it.
Tristan Rhodes wrote: There are a number of similar style controls (View / Editor combo)
Tristan Rhodes wrote: These form a composite control
Tristan Rhodes wrote: I'm trying to get the manager control to handle the Selected event in the tree view / list and pass the focus to the editor control
So if this "editor control" is one of your custom controls you should say that rather than editor control which is interpreted as edit control, hence much confusion.
Anyway if I now understand correctly, don't use the focus event. If this is your custom control, in fact they all are I guess, you should have a design that is yours. It could be events or messages it doesn't matter but it should be yours. Don't try to use the framework events as your custom events, that is probably not a great idea even when it works.
This is not a topic I remember Kent Beck covering in Implementation Patterns, but I imagine he would say something like "prefer explicit design to implicit" as it is easier to understand.
|
|
|
|
|
Hi Mike,
I'm not trying to use any custom events, i just want to be able to handle a change of focus on my control so i can implement some specific behavioral logic. It's not (or shouldn't be) a complicated task. I'm happy with the application design as is, and I don't really want to have to implement my own system for something that already exists that just needs a bit of custom tailoring.
To sum up the process:
* User selects MenuItem in treeview
* TreeView raises selected item change
* Selected MenuItem is loaded into MenuItemEditor
* Focus is passed to MenuItemEditor
* MenuItemEditor passes focus to TextBox. //OnFocus / Focus event not hit
* User edits TextBox Text.
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Are you handling an event or overriding OnFocus? If you are overriding the method, do you still call base.OnFocus()?
|
|
|
|
|
I override the OnFocus method as the event wasn't getting raised. The OnFocus method never gets hit either for some reason.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
You'll have to research this a bit I'm afraid. For some reason (there must be something better than anything I can think of) Microsoft has this incredibly elaborate design for this stuff which means simple logical code you'd expect to work just doesn't.
Unfortunately it seems that the TreeView is doing something *after* the *After*Select event that causes the active control to be reset to whatever tree node you were working with.
It's not elegant, but I worked around it using a Timer control and an instance member to refer to the control I want to activate, a la this:
Control ctrlToActivate;
void timer1_tick(object sender, EventArgs e)
{
if (ctrlToActive == null) return;
ctrlToActivate.Select();
ctrlToActivate = null;
}
void tree_afterSelect(object sender, TreeViewEventArgs e)
{
tabControl1.SelectedIndex = int.Parse(e.Node.Tag.ToString());
foreach (Control c in tabControl1.SelectedTab.Controls)
if (c is TextBox) { ctrlToActivate = c; return; }
}
The timer event is on the UI main thread so basically the message loop of the window will call the handler whenever it's doing an iteration and finds that the timer's interval has expired. It's not really expensive so you can use a short interval like 30 milliseconds, but there surely ought to be a much easier way to achieve this. I can only suggest you study the model because clearly focus and selection and "currently active control" are related but not identical concepts.
Finally, a word on terminology. I wouldn't call this bubbling. Your control is a container that when receiving focus (or perhaps when "being activated" which apparently is not the same thing) should in turn activate/focus a particular child control. Bubbles rise - and I think most people think of event bubbling the way it works in DHTML: An event occurs on a control, and if there's a handler registered with the control for the event it executes. Then the event may bubble to the parent control of the "event source", and again handlers may execute. This allows the user to attach a handler to a container and handle events that originate in the child controls - such as a mouse click anywhere in a table without having to register handlers with every row, cell, and content controls inside it. What you're doing is pretty much the opposite - you're not bubbling an event to a handler somewhere up the control tree, but rather "rippling the event" or causing a domino effect so that when the event occurs on the parent it also occurs on a child.
I'm fairly amazed at how complicated Microsoft sometimes manages to make even the functionally/conceptually simplest of tasks. To be fair, with .net they've often made it easy to do formerly complicated things, but this is frankly ridiculous. Trying to find anything in the documentation is awful - you have to take bits and pieces from Control, ContainerControl, the IContainerControl interface for container controls that don't inherit from ContainerControl (such as the TabPage, which inherits from Panel, ScrollableControl, Control, object -- meaning the Panel isn't a ContainerControl either..!?!), Form.ActiveControl, and more, and consolidate the reference-style information here into something that resembles a logical model for controlling what control is active in your application. Maybe the nature of the problem really is so intricate and complex that this is to be expected, or maybe Microsoft did a truly bad job with this part of the FrameWork. Or maybe (my real hypothesis) it is necessary to conform to certain *windows* (as opposed to .net) concepts that are hideously complicated and make it impossible to come up with a simple way to activate a textbox when a user clicks a node in a tree. One would not think this should be hard, but just google for Focus() and Select() and "active control" and "set focus .net windows forms" and you'll quickly see that a LOT of people are finding this a daunting task.
|
|
|
|
|