Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
Why are you having to do this? On my system (Windows XP) this is the default behavior. That is, tabbing into a textbox autoselects everything the first time through. Only on subsequent passes does it change. As Volte pointed out, traditionally, tabbing in should auto-select but clicking should not. For that behavior, using the Enter event would be perfect. But who knows what your users want? I'm glad you found a solution that they like :) -Nerseus
-
You can also modify the template forms. There might be a way to add new templates, but I haven't looked. Using C# as an example, I changed the following file: C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddWinFormWiz\Templates\1033\NewWinForm.cs Whenever I add a new form it uses this as the file. It does some fancy replacing so don't modify it too much. I removed most of the built in comments and added some regions, much like you're asking for. Plus a few more using statement (Imports in VB) that I use all the time. -Nerseus
-
Why wouldn't you want to use LookAtLH? Just to learn the math yourself, or...? I can't help you with the math part but I'm sure there are plenty of 3D math tutorial sites on the web, especially those setup to help do common matrix math like setting up view matrices. -Ner
-
Nothing built in, but here's a good resource. -ner
-
If you're using a bound grid control, you're essentially asking to dynamically create a new column (only up to 5) as you go. I'd think it's possible, but I'm not sure if you can trap the "tab" key in the grid to automatically add the column as they tabbed out of the 1st column (to create the second column). If you have to handle deleting columns you might be in trouble :) I have a project that needs a dynamic number of columns and rows and I generate a dataset and the matching rows/columns ahead of time. I chose to use dynamically created textboxes in a scrolling panel control to mimic a grid. It's not that much code and works very nice, but has the side effect of being pretty slow (much slower than you'd think for creating 12-15 textboxes and 8 or 9 labels). Why not just create the table with 5 columns and not worry about it? -Ner
-
Transfering informatin between forms without dimensioning as withevents
Nerseus replied to DiverDan's topic in Windows Forms
You can create a public static (shard in VB?) method in the class/form that handles showing the form. Something like this (sorry for C#, but you should be able to convert): In frmPopup, the shared form: // Inherits from form public class frmPopup : Form { private frmPopup thisForm = null; // Nothing in VB // Constructor is private so no one else // can create this form private frmPopup() { } // Method to get the form - use instead of: // Dim f as frmPopup = New frmPopup() public static frmPopup GetForm() { if(frmPopup==null) { // Constructor is private, but this form can still create itself frmPopup = new frmPopup(); } return frmPopup; } } In the calling forms: public class frmUser : Form { private frmPopup myPopup = null; private void SomeFunction() { // Call the static method of the class // Which returns an instance of frmPopup myPopup = frmPopup.GetForm(); myPopup.ShowDialog(); } } The idea is that the popup contains a private reference to an instance of itself. Access to the form is only granted through the static method, which returns a new instance of the form the first time it's called. On a second call, it returns the same instance. In C# you don't have to declare a variable as "WithEvents" to have access to it's events. In VB.NET, if you declare the myPopup variable in frmUser as WithEvents it should be fine. I have a sneaking doubt that you can't create the frmPopup if the constructor is private. If that's the case, make it protected (not sure of the word in VB.NET - you want it so that only the current form or inherited forms can access it, not Friend which is all forms in the assembly). -Ner -
I assume VB.NET has some kind of documentation feature like C# (maybe?). In C# you can add /// comments. If you add them above a function, it automatically scans the parameters and creates little sections for them in your comments. Later, you can build documentation from those comments. Why am I mentioning this? Hopefully just about every function you have has at least a one line comment to describe it's general purpose and intended use. If so, those comment blocks are a great way to see where one function ends and another begins. You can also set up Regions in code, which are collapsable areas of code. I know I didn't answer your question, but... I used VB for years and loved the function separater and loved it. I missed it for awhile but didn't find a way to get it back (not in VS 1.0). But after about a week, I didn't miss it anymore. It might be back in VS 1.1 but I haven't looked. -nerseus
-
Well you have three basic options if you want to keep the code separate from your main EXE project. 1. Put your validation or forms (or whatever!) in a DLL. 2. Use a "schema" or some custom XML-type file for validation. 3. Use compile-on-demand. 1. You could create a DLL with a class specific to a form that handles all the validation and exposes a method or two (whatever you need) such as "ValidateForm()". It could even host a form that displays custom errors. A DLL is the fastest, execution-wise, but means separating out your logic "far" from the form. 2. In my current projects, we store our validation in XML format (based on a modified version of a "standard" for validation - can't remember the name right now but it's weird). The concept is to code an "assert" that evaluates to true or false. You reference data in the dataset (whatever rows/columns you need) and it returns a true or false. It works well because we can put the validation right in the same XSD file that stores the data. An XSD is an XML file that represents a DataSet. A typical "assert" might look like (it's XPath, a query language for XML): test="/*/Customer[not(FirstName) and MiddleName]" That means, return rows in Customer that have no FirstName (it's null in the table) and have a MiddleName. If that returns a row (asserts as true) then there's an error - meaning the user needs to get a message that this isn't allowed. It's messy (XPath can be quite lengthy at times), but it's very dynamic and it keeps the rules with the data. 3. To compile on demand, you basically have C# or VB.NET code in a file and load it, compile it, and run it at runtime. You can actually invoke the .NET compiler from within code. I've not done it but there are numerous threads on this forum, many by divil, that explain how to do it. It's very flexible, but means you need to store that extra raw code somewhere on a client machine or download it at runtime and compile it. It's more robust than a DLL but also harder to implement and test. Also, it will take a tad longer since it must be compiled (again, I haven't tried this but I assume this time is pretty insignificant assuming a small piece of code). There are probably many other options, those are just the ones I've tried or heard of. -Ner
-
Whoops, neither of those work. Try this -nerseus
-
I tried both a Win32 Console project (unmanaged) and a .NET Console project (managed). It worked find for me. I put a breakpoint on the call to CharToBin (mine just casts c to an int) and pressed F11 and it stepped right into CharToBin. I'm not sure what the following line does. I removed it from my test: character:" ; It won't compile with it in. Maybe there's a project property that you've changed (I have no idea). I have a default setup of C++ .NET with only a few extra Library directories (Tools->Options->Projects->C++ Directories). Can you post your test app? -Nerseus
-
Assuming the Length property of a string is an accurate measurement of the string's maximum length (it's an int), you can use Int32.MaxValue (around 2 billion as BOC mentioned). -Ner
-
Yes, but at a minimum there's going to be some kind of 2 dimensional array being used (or something more complicated). Since he's asking such a broad question, I wanted to know if he's ready to do that kind of coding yet or maybe needs some basic programming lessons before tackling something bigger. -n
-
I'm not sure how setting the Width and Height of newTransportRecord will have any effect if it's a maximized child window? I think your question is how to show newTransportRecord "maximized" but also show another form (form header?) docked to the top of the MDI form? If form "form header" is a docked window (no built-in support for this in .NET that I know of, though many 3rd party tools do this), then maximizing the new form would be fine. If your "form header" form is just a child window then you can't maximize your newTransportRecord form. You'd have to try and resize it exactly the size needed using the MDI's ClientSize property along with the size of the "form header". I'd look into getting "form header" docked first, that should take care of your problem. As a starting point, search for dockable windows in google and see if there are some free dockable window controls (classes) that you can use. If not, I'm sure you could find some cheap ones (and expensive ones depending on your needs) for sale. -Ner
-
I'm not super-familiar with validating things in the DataGrid, but I'll throw out a few suggestions anyhoo. Have you tried using ColumnChanging to see if you can get to the value before it goes in? A question: Can you set the DataSet directly, instead of the Grid's Item property? I don't know what your code is doing to manually set a cell, but can you set the column value directly in the DataSet? When using bound controls it's usually easier (and cleaner) to set the DataSet directly and have the contol update. Where is the data coming from that you're setting manually? Can you not format the data before putting it in the grid/dataset? If you can put data directly in the DataSet, you could check the DataSet's maxlength and not even get into the ColumnChanged. It slightly duplicates code, though both places (your manual updating and the column changed event) could use the same validation function. -Nerseus
-
I'd go back to your original idea of using the OuterHTML and using the LoadXml method. The problem with navigating directly is that the page is expecting a form to be submitted. You can't duplicate that in just a URL. I'd "look at" the string in OuterHTML and possibly save it to a file for testing. I'd bet a dollar that the XML just isn't valid. If there are any HTML tags along with the actual XML data, they're probably not meeting the strict requirements for XML. For example, in HTML you can have "<td nowrap>". In XML all attributes must have a value, as in "<td nowrap="true">", but that's not valid in HTML :) Also, many elements don't require a closing tag, such as "<p>" and "<br>" but XML does require them. Those you can mostly fix by changing them to "<br/> or somesuch (I think). You may have to extract out the XML from the OuterHTML string, some simple string manipulation might do it, based on what the HTML looks like. If you want help, show us the value of OuterHTML so we can take a peek. -Ner
-
Personally, I hate being forced into one exact format such as mm/dd/yyyy if I want to type m/d/yyyy (for instance). Granted, it's perfectly acceptable to reformat the m/d/yyyy to mm/dd/yyyy after the tab out (one option) to ensure the data matches a specific format. And I agree that data-entry forms should not require any mouse movement, or at least keep it to a minimum. Having said that, the DateTimePicker still sounds perfect. You can set the format to "Custom" and the CustomFormat property to "MM/dd/yyyy" (note the capital M's - lowercase is for minute). That forces the format you want and yet they can still type exactly what they want (or less, if they like typeing "m/d/yyyy"). While you can look at the MaskEditBox, it's painful (in my opinion), and overkill for dates. If you use a textbox, you have more control (you can try DateTime.Parse) since you can validate however you want and even convert values. For example, I've had projects in the past where we allow certain characters to be entered that get parsed into dates. For example, enter "t" in our special textbox and when you tab out it gets today's date (DateTime.Now.Date). Enter "y" and it gets yesterday's date. Enter a single number between -30 and 30 and it went that number of days in the past or future. It requires a more custom solution but gives more flexability. -Nerseus
-
There are lots of ways to read textfiles. I like the following: StreamReader reader = File.OpenText(@"c:\file.txt"); string stringFromFile = reader.ReadToEnd(); Then you can set the RTB's rtf or Text property (I forget) to your two strings, appended together, like: rtb.Text = myString + stringFromFile; -Nerseus
-
@Merrion, lol :) edit: split thread to Database forum -Nerseus
-
It's probably not valid XML (missing closing tags, invalid attributes, etc.). If you use Try and Catch(e as XmlException) you should be able to view e.Message to get the exact error, line number, and position. By the way, LoadXml loads a string, Load loads a stream from a string (a filename, url, etc.). There was confusion earlier, I think. -Nerseus
-
C++ Lib -> Dll (Wrapper)
Nerseus replied to chuawenching's topic in Interoperation / Office Integration
Have you considered other engine, such as ODE, to handle your physics? It may have the same compiling/language problems, but at least you get the source code... I haven't worked with Tokamak so I can't say how it works. If it just exposes functions, you can probably work with C# by creating all the propery DllImport lines in your C# code. Of course the easiest way to use that engine would be to use C++, but that means learning C++ which is generally a LOT more than just the language. This is different than C#, which you can learn relatively quickly. If you want to learn C++, I'd first go through a C++ book, NOT a Visual Studio C++ book. You'll really want to learn C++ before you learn C++ in .NET. After you feel comfortable with C++ (maybe as soon as week or two, depending on how much time you have and how fast you learn), you can use a Visual Studio C++ or C++ .NET book to learn about C++ in .NET, or just read through some online tutorials and MSDN. The big issue is setting up include directories, library directories, excluding libraries, etc. If Tokamak is made for standard C++ libraries, you might also run into issues using managed C++ if you're using .NET 2003. They moved a bunch of the standard libraries, such as iostream, to a new namespace and it means pretty much NO compatability with older C++ code. It's a pain. If you get that far, ask lots of questions, maybe we can help :) -Nerseus -
I think you'll have to load the string manually and then shove your original string plus the loaded text in to the RichTextbox yourself. You could also add the string to the front of the textbox after you load the file, but you might notice a visual glitch. Not sure if there's a way to suspend drawing on the RTB while adding text or not. -Nerseus
-
I'm not sure about the memory usage - the garbage collector should be clearing out the original bitmaps when it runs (when it determines it should) as there are no references to the original image. By the way, I'd rename your variable from Image to something else that doesn't match the class name (I'm surprised VB even compiles that). As for the response time, you can call Application.DoEvents() in your loop to give the machine a chance to process windows messages (allows moving windows, switching to other windows, etc.). Basically allows your CPU intensive operation to play nice with the OS. -Ner
-
First, I'm not sure you can save a multi-image file as type Bitmap. You may need to use a Tiff or gif or something similar. I've never tried this so I can't say that for sure. But, here's a link to a solution. You'll have to register (it's free) to view their forums. I don't want to paste the code here as it would be in bad taste (more or less stealing, since they want you to register to view answers). I did get the multi-page Tiff to save, btw. From the looks of the answer given, you'll have to add a few more params and do a little more than what you've got. -Nerseus
-
I'm not sure of the speed (which is faster), but you can also try: Dim lastLinePos As Int = s.LastIndexOf("\n") If lastLinePos = -1 Then lastLinePos = s.Length End If s = s.Substring(0, lastLinePos) If you only have one line, the above leaves it there. If you want to delete the last line as well, change the "If" to If lastLinePos = -1 Then lastLinePos = 0 End If Just another option :) -Nerseus
-
@Volte: I think he meant a mask, not a picture, though I was confused at first, too :) @Drstein99: You can use the Mask Edit control for this, but I would think you'd really want the DateTimePicker, which support a nice dropdown calendar as well as providing built-in support for checking on valid dates. -Nerseus