Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
I'm not sure what you're doing, but the class CustomRowEventArgs has a constructor that's doing this: barry11 = barry11; I think you want: barry11 = DSet; -ner
-
It depends on how the index will be used. An index won't get picked unless the first column(s) are used in a query. Suppose you put columns A, B and C in an index like so: CREATE INDEX idxTest ON TestTable(A, B, C) A query using column B or C (or both) will not use this index. Indexes are a tricky business to figure out. If the table does not get a lot of INSERTs, then you could consider adding multiple indexes (one on each column) and one or more multi-column indexes if needed. Now, if you always join to this table on all 3 columns, then it would help to put all 3 in the index. -ner
-
The closest I can come up with is this: ControlCollection a = new ControlCollection(this); a.AddRange(new Control[] {checkBox1, checkBox2}); You could wrap this in a function if you wanted: public ControlCollection CreateCollection(params Control[] controls) { ControlCollection a = new ControlCollection(this); if (controls != null) a.AddRange(controls); return a; } // Call it like this: ControlCollection a = CreateCollection(checkBox1, checkBox2); -ner
-
I did a google search for "IP Address textbox c#" without the quotes and came up with the following: http://www.codeproject.com/cs/miscctrl/IPAddressTextBox.asp He address a LOT more issues that you were/are probably interested in, but still might prove useful. Glad to see you got the parsing fixed. :) Note: I didn't actually look in detail at what was posted so I'm not saying it's definitely an example of clean code. Just thought I'd offer up the link in case it happens to work for you. -ner
-
The behavior I see is that each child window does get colored in the "Active Window" titlebar color while the other child windows remain in the "Inactive Window" titlebar color. The MDIParent window itself always shows up as the "Active Window" for the titlebar color. If you maximize a child window, it's caption (Titlebar's Text) is incorporated into the MDIParent window's title. The text changes from: Form1 to Form1 - [Child1] I can post a test project if you'd like. Or maybe you could post yours? -nerseus
-
Have you tried closing Visual Studio in between? It won't update until after you close. I've also noticed that if you have 2 or more Visual Studio's open at once, it won't always save your project to the MRU (most recently used list). You can check out your options for how many to dispaly in case it's 0, but the default is 4 I think: Tools->Options->Environment->General and look for "Display ___ items in most recently used lists". 20 is the max and works for me. -ner
-
I can't help too much since you need a 1.1 grid so I'm glad you found the FlexGrid! We do LOTS of custom drawing in our grids but it's with DevExpress which supports that (we draw lots of icons per cell based on all sorts of criteria). I haven't looked at the 1.x grids very much. I know the 2.x grid (DataGridView) from MS will probably do everything you'd want, but if FlexGrid also works then go for it especially if you're using the 1.x framework. -ner
-
Note that if the code is in your class, it's generally better to override OnLoad than use the Load event. Maybe I'm being nitpicky, but thought I'd mention it since many people don't know about OnLoad. -ner
-
It depends on what you want to do, using the indexer on "this" is valid if that's what you wanted - but you described something else. Suppose you had this code to create a Collector: Collector c = new Collector(); Now, if you wanted to index into c itself, then you'd use the "this" indexer: // Inside the class... public int this[int index] { get { ... } set { ... } } // The code using the class: Collector c = new Collector(); c[0].Field = ""; // The [0] uses the indexer If you wanted to have a property named Items, then you'd use the property: // Inside the class... public List<Item> Items { get { ... } } // The code using the class: Collector c = new Collector(); c.Items[0].Field = ""; You can, of course, implement both if you wanted to. That would make it look like the "Items" property was a "default" of the class (so that c[0] and c.Items[0] are the same thing). It really depends on what you want. Since your class is called Collector, I'm guessing its purpose is solely to collect things - in that case I'd use the indexer and not expose an Items property. For that matter, if you don't really need your own class, you could just declare instances of List<Item> as needed. -ner
-
The first thing that comes to mind is exposing the collection: using System; using System.Collections.Generic; public class Collector { private List<Item> _collection; public List<Item> Items { get { return this._collection; } } // Other members, properties, and methods public class Item { // Members, properties, and methods } } -ner
-
This has nothing to do with programming, but it's computer related so I thought I'd share. I've been using a wireless router at home for about a year now but I didn't secure it - I had some trouble with drivers early on and didn't want to mess with things once it was working. My son wanted to play a 2 player LAN game so I finally broke down and setup the encryption on the router/wireless adapter. The nice part was that the D-Link site (my router and card) had this in their FAQ and it worked on the first try. Maybe it's a sign of the times that I AM surprised that things went smoothly. I'm glad things are working! Since the wireless adapter is in my wife's computer, I chose to use the 128 bit encryption - a bit slower, but she mostly just cruises the net. :) -ner
-
Here are the ones I tried (pretty briefly) - and my tests/reviews were all done in Visual Studio 2005 w/ .NET 2.0: Microsoft: DataGridView DevExpress: XtraGrid ComponentOne: TrueDBGrid Janus: GridEx 9Rays: FlyGrid Note that ComponentOne also has a FlexGrid, which seems more like Excel. I was looking at grids that bind and the C1 help indicated the TrueDBGrid would be more what I was after. Summary of each grid: MS DAtaGridView I really like the MS grid, but it didn't support hierarchical. We're still looking into this one for non-hier grids and it looks very good and VERY fast. We did some research into making it hierarchical based on this blog, but more or less abandonded it as being too time consuming and prone to errors - we'd rather buy than build this type of control. DevExpress: This is what my company currently uses (version 2.x). I did a quick test of the 3.x grid and it appears mostly the same. It's nice - and it comes with full source. The version we have is currently in production so we can't easily upgrade and it's got a few bugs. It's not the best grid in the world, but it has a TON of options and good support. We've requested a few features get added (via their forums) and they showed up in a future release, which was nice. The main problem is that there are 100 ways to do anything with DevExpress and you can't always find the right way, easily. The help is getting better which is a big step. The other major con is performance - the initial time to load up a form that uses a DevExpress grid is by far the longest. It's got to be one of the "heaviest" 3rd party controls I've ever used. Feature-wise, it's topnotch. ComponentOne: The TrueDBGrid's hier' grid didn't draw the way I expect - the child "rows" show up as additional columns. That's how it appeared in my test and in their 1 hier' tutorial project. I sent them an email, but I'm waiting to hear back. As it stands now, I gave up on them since I was looking for a hierarchical grid and this just didn't work for me. I've heard LOTS of good things about C1, though. Janus: This one looks really nice, visually. I didn't play with it that long but I really liked the look and ease of use. 9Rays: I gave up on this almost immediately. It took about 10 minutes of reading their help to figure out how to bind the grid and I could never get it to show columns and rows. Normally in binding you set a DataSource. The 9Rays grid wanted me to bind to a Rows property, which threw me off. I didn't want to get stuck with a product that's "easy" to use IF you developed it, but non-intuitive to the rest of us. Maybe I didn't give it a fair shake, but with so many other options, this one wasn't worth my time. As far as what I did FIRST, I created a Word document of all the core features I want/need in a grid. This was based on what we've been using in grid controls for years. I left out some features that we use, but that we don't need. For features, I put in things like "need alternating row colors", "need read only grids", "need custom drop downs", "need drop-downs that are filtered per row", etc. Then I went looking for controls that would meet that need. Right now, I've got it narrowed down to DevExpress and Janus, both similarly priced. I'm handing off the investigation to someone else who has more time but I can report back what we go with if you'd like. -ner
-
For the few events that I've created, I used custom delegates that didn't follow the standard "sender as object" parameter. The other developers I've worked with that saw the code knew instantly what was being passed and why so there was no confusion. I've rarely had the need to use and the sender parameter in my events as I usually have one event per object and I don't generally point multiple instances to use the same event. Maybe I don't know enough to use them correctly? :) As an example, I have a small batch job that reads and parses a file and then does some other stuff. The parser object uses a delegate declared like so: delegate void LineProcessed(int currentLine, System.ComponentModel.CancelEventArgs e); One of the classes using the delegate is declared like so: internal sealed class FileParser { private FileParser() {} #region Events public static event LineProcessed OnLineParsed; public static event LineProcessed OnLineScrubbed; public static event TotalChanged OnTotalChanged; public static event ScrubStart OnScrubStart; private static bool RaiseLineParsed() { CancelEventArgs args = new CancelEventArgs(); if (OnLineParsed != null) OnLineParsed(parsedLines.Count, args); return !args.Cancel; } private static bool RaiseLineScrubbed() { CancelEventArgs args = new CancelEventArgs(); int currentIndex = (parsedLines.CurrentIndex > parsedLines.Count) ? parsedLines.Count : parsedLines.CurrentIndex; if (OnLineScrubbed != null) OnLineScrubbed(currentIndex, args); return !args.Cancel; } private static bool RaiseTotalChanged(int totalLines) { CancelEventArgs args = new CancelEventArgs(); if (OnTotalChanged != null) OnTotalChanged(totalLines, args); return !args.Cancel; } private static bool RaiseScrubStart(string message) { CancelEventArgs args = new CancelEventArgs(); if (OnScrubStart != null) OnScrubStart(message, args); return !args.Cancel; } #endregion ... } The code inside of the FileParser classes calls RaiseNNN whenever it wants to raise an event. There's no need for the code consuming this class (and its events) to ever need access to the FileParser class itself, within the event, so I don't pass it. The code in the consuming class hooks up the events like so: FileParser.OnTotalChanged += new TotalChanged(OnTotalChanged); FileParser.OnLineParsed += new LineProcessed(OnLineParsed); FileParser.OnScrubStart += new ScrubStart(OnScrubStart); FileParser.OnLineScrubbed += new LineProcessed(OnLineScrubbed); lineList = FileParser.Parse(sourceFile); FileParser.OnLineScrubbed -= new LineProcessed(OnLineScrubbed); FileParser.OnScrubStart -= new ScrubStart(OnScrubStart); FileParser.OnLineParsed -= new LineProcessed(OnLineParsed); FileParser.OnTotalChanged -= new TotalChanged(OnTotalChanged); Now, a separate question would be: Why the weird syntax to unhook an event? I hate having to declare a NEW instance of a delegate, to unhook the existing one. The syntax just seems awkward. Having said all that, if I were making a custom control that could get sited on a form, I'd probably stick with the "sender as object" syntax, just in case someone wanted to hook up multiple instances to the same event. -ner
-
The only free gridcontrol I'm aware of is SourceGrid. Check it out at: http://www.devage.com/ I have only used their sample, never really looked into it that deeply. I was investigating hierarchical grids, which SourceGrid is NOT, so I gave up looking at it. There may well be other free grid controls - don't give up searching yourself. btw, most grid controls are around the $300 range for one license. That is WELL worth the price, if you ask me. -nerseus
-
Actually, if I were writing a safe function, I'd want to check negative values - I was trying to demonstrate a check against the Length property. I hate out of bounds exceptions but glad that there's no memory leakage or buffer overflows :) -ner
-
If it's a regular array, compare the index to the Length: string[] test = new string[25]; // Count will be 25, indexes 0 through 24 ... private string GetValue(int index) { if (index > (test.Length - 1)) { // Handle an index that's too big } else { return test[index]; } } -nerseus
-
You can definitely go custom and the method you describe may work well for you. I did a google search as I'd heard about "license" features built into .NET but never used them. I googled for: site:microsoft.com license control It turned up this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconlicensingcomponentscontrols.asp That should be a starting point, if nothing else. -ner
-
If the controls and grid are bound to the same DataSet then the changes should update immediately. If you use a different dataset, you'll have to manually refresh the grid's dataset after you save to the DB. The two connections shouldn't matter - it comes down to what you're binding to the grid. -ner
-
You can see the parameter values in VS. In the Call Stack, double click on the line you want and then you can examine the values from the context of that call. For example, look at this C# program: static void Test2(int i) { Debug.WriteLine(i); } static void Test(int i) { i++; Test2(i); } [sTAThread] static void Main() { int i = 5; Test(i); } Set a breakpoint on the line "Debug.WriteLine...". If you look at i, it shows 6. In the callstack, find the line and double click it: Test.exe!Class1.Main() Line 34 Now if you examine i, you'll see it's still 5. It's showing you that it passed 5 to the function Test. The key is the double click in the Call Stack, which sets context to that line of code. -ner
-
You're looking for Dynamic Help maybe? Go to the Help menu and turn it on (Ctrl-F1 in my VS). -nerseus
-
I've watched a few episodes, mostly from "channel 9" (I think that's the name). I watched the episodes that talked about the new features of VS 2005. I have a coworker that watches them first and tells me which ones are good - he's like my personal Tivo :) You can get to them from: http://msdn.microsoft.com/showsandwebcasts/ I used to have a link to "Channel 9", I think, but it was awhile ago. Maybe they've renamed it since. On a side note, I don't know where this came from, but it was REALLY good. It's about how Microsoft does Software Engineering and covers a LOT of ground, including the various roles people play (analysts, developers, managers, etc.), how they use source control for such large projects, how they do unit testing and enforce things like check-ins, etc. etc. etc. Very good "show" (the video is just a recorded Powerpoint show which is very grainy, but the audio is good). http://www.ftponline.com/channels/net/reports/vslivesf/2006/multimedia/ryan.asx -ner
-
The function ProductGT11 should take a single parameter that matches the type of the array - in your case a string. So the definition should be: Private Shared Function ProductGT11(ByVal p As String) As Boolean I just removed the parens from the parameter "p". -ner
-
For me, if I know it's a number that I'm storing, I'd rather use a bigint than varchar. I'm thinking ahead to when this is read out - if it's varchar, there's a chance someone will put the letter "a" out there. I hate writing conversion programs for older systems where everything was a varchar, even dates, and you get those weird anomalies that won't convert right. If this is a number that "looks like" a number but isn't (like an SSN), I'd definitely store as varchar. -ner
-
Here ya go, just typed this up so it may not be 100%: select [text] from syscomments where id in ( select id from sysobjects where xtype = 'tr' -- trigger and parent_obj = ( select id from sysobjects where name = 'TableOfInterest' and xtype = 'u' -- user table ) ) The inner select uses sysobjects to get the id of the table you're interested in. The next select uses sysobjects again, to get the triggers for that table (using parent_obj). The outer select gets the text. If you've turned on the SQL Server option to hide the text, you're out of luck. SQL can be made to only store the compiled objects. -ner
-
I'm using Visual Studio 2005 (not an Express product) and I found the option under: Tools->Options Environment->Startup It says "At Startup:" and you can choose what you want from a list. -ner