Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
Running from in the IDE in Debug mode is tremendously slower than running from an EXE in Retail mode (what a user will experience). I felt this fear as well but I'd try out your program the way a user will experience it first and see if you have reason to worry. -Nerseus
-
What level of programmer are you, Phreak? If you're fairly new I'd suggest scaling WAY back and just try to write a simple chat program and worry about adding SQL Server and encryption and such later. Just a suggestion :) -Ner
-
If you need the domain and username, use: System.Security.Principal.WindowsIdentity.GetCurrent().Name -Ner
-
While you *could* do it in GDI+, you'd be doing all the 3D work yourself. It's not terribly complex, but if you want rotation, changing perspective, etc., it's NOT going to be trivial. If you want to code it yourself you're probably going to want to use Direct3D (as you guessed). If you look at the DirectX8 (not DX9) samples, you'll find a Bar Graph sample done in VB6 that includes a "picker" - as you hover over each bar it gives the numbers in a floating tooltip. You can rotate, zoom, etc. in the VB6 sample. Obviously, you'll have to convert the whole thing to DirectX9 if you want to do it in .NET but it shouldn't be that hard (except for maybe the "picking" part). -Ner
-
The locking during a SELECT depends on your isolation level. Look at the command "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE" (or the other 3 types of locking) for more info. You can also add the (NOLOCK) optimizer hint to your select, as in: SELECT * FROM Table1 (NOLOCK) INNER JOIN Table2 (NOLOCK) ON Table1.Col1 = Table2.Col2 Depending on the database locking, your update may lock a row or the table. SQL Server defaults to Row-Level locking (I think) so you should be Ok there, but you should probably read a few pages of the Transact SQL Help (under Query Analyzer's Help menu - easier than using Books Online sometimes). -Ner
-
An old-school "cheat" is to position the tab control partly off the form (by setting it's Location to -16 or whateve the tab height is). You could also "cheat" by placing a panel on top of the tabs, to hide them - in case you can't move the tabs to the edge of the form. divil's idea is another alternative that I've used. It works especially well for smaller wizards where you don't have to worry about so many panels. If you get too many, it's hard to keep track of them in the designer. -Ner
-
You can go to the InitializeComponent function and look for the line "TabControl.AddRange" where TabControl is the name of your tab control. You should see a comma-separated list of the TabPages, just move them around there. You can also use the Designer. Get the TabControl in the properties window, then click on the ... button next to the TabPages property. In the dialog popup, you can use the up/down arrows to move TabPages around. This happens from time to time. I can't reproduce it regularly, but I've seen it happen a few times. -Ner
-
You need to redim the array Obiekty. I'm not sure if the ReDimming part is right - someone can correct me later :) 'Snipped the structs definitions... Dim dc As typeStrony ReDim dc.Obiekty(1) dc.Obiekty(0).Left = 14 'The following will fail because Obiekty is only defined to have one element, (0) dc.Obiekty(1).Left = 14 -Nerseus
-
A DataSet is a handy-dandy way to store the data client-side for doing all your work before sending it back up. It allows for multiple tables, linked if you want (like a real relational DB - sort of), plus a LOT more. It's also serializable, meaning it can be represented in 100% text for easy sending over the internet (to return from a webmethod). If you want, you could use a DataReader to get the data locally but you usually want to store it somewhere besides the textboxes the user is editing. A grid, for instance, needs to be bound somehow - usually a DataSet though you could fill an ArrayList from a DataReader. You may want to check out MSDN online (free) to see the main differences between ADO and ADO.NET. There are a LOT of differences to be aware of since using .NET is a LOT different than using VB6. It's more than just syntax changes - it's really a different way to structure your code and logic and ADO.NET is a part of the "big picture". -Nerseus
-
It's still up to you to decide how much data-tweaking can/should happen client side versus server side. For instance, I have a solution that manages data in three areas: client side, web-server "side", and in SQL Server. The idea behind disconnected data is meant to limit the number of active connections to a database, not where/how you manage your data. The one main difference is in locking. In a disconnected scenario, you don't hold any hard locks on the data. If you need to lock anything, you'll have to do it through code or flags on the database (such as using a timestamp column or a bit flag or username). You can definitely use stored procedures in ADO.NET to do your SELECTs, UPDATEs, INSERTs, etc. and even have very complex queries. For instance, my app passes XML (from a DataSet) to SQL Server which can treat the XML like a table to pull out the data for INSERTs, UPDATEs, etc. You must manually grab the identity (@@IDENTITY) yourself if you do this, whereas using a DataAdapters Update method will automatically update "identity" columns in the DataSet if used properly. That's a bit more than you probably wanted :) If you have specific questions about where to do specific things, you might get a clearer answer (such as if you need to know how to pass data to a proc to do your major manipulations - I mentioned XML above, but that may not work for you). -Ner
-
You must be using the ActiveX version of the Tab control? The .NET version doesn't support an Item property off the TabPages collection (that I can see)... Unless you're coding everything in a loop (referencing ALL controls on every tab in a loop), I still don't see why you can't reference each control by name? Why not use txtDueDate1, txtDueDate2, etc.? If you ARE using a loop, there are a number of suggestions above... I guess I just don't see the issue. -Nerseus
-
I'm not really sure what you're looking for... optimization, coding technique, or...? In general, it looks pretty good. There are a few shortcuts you could take for coding, but they're just preferences (such as "var++" instead of "var = var + 1"). I would probably use Column names instead of indexes (in your GetString() calls). If you have to use indexes, add a comment so you know what those columns are later. Same thing for the button indexes. I'd make a list of constants or an Enum so that you don't have to guess what those numbers mean one day. Also, you could probably use an ArrayList for arrFac instead of a hard-coded array. Since mMode and mFac are Public Shared, do you really want the "m" prefix (usually for private member variables)? One last thing. I'd change the command string to check for embedded single quotes, as in: cmd = "SELECT * FROM Fac WHERE Fac_Code >= '" & sFac.Replace("'", "''") & "' ORDER BY Fac_Code" -Ner
-
Whoops, no such thing as Cursors.None. :) bpayne111 is close, just leave off the Me, as in: Cursor.Hide() and Cursor.Show() -Nerseus
-
Actually, it's not that inefficent to loop through every control. But I can see your point of not *wanting* to do that. In that case, you should look at some of divil's suggestions. Have you actually done any code yet, by the way? I'm asking because you say you want to disable certain tabs which isn't possible with the built-in Tab control. You can hide tabs (remove TabPages from the TabControl), but not disable. Also, how did you plan on referencing your TabPages by number? You'll have the same issue of looping through all the controls to find one by name (granted, you can loop through the TabControl's Controls collection - very fast). Can I assume that each tab page has pretty much the same controls, all named sequentially? If so, you might do better to put the controls in a UserControl. Then you only have to find one control by name (UserControl1 for instance) and reference all the child controls by name (txtDueDate - no sequence number). -Ner
-
How to set Datagrid Column Properties?
Nerseus replied to melegant's topic in Database / XML / Reporting
Can you use the DataColumn's ReadOnly property? For instance, suppose you have a table in your dataset named Table1 and a column name ID: ds.Tables["Table1"].Columns["ID"].ReadOnly = true; -Nerseus -
A couple of questions/suggestions: First a question: why not just use txtDueDate2.Text = "value"? Why must you use them as a control array? If you're creating them by hand, you can use the same name for each control... Another question: If the controls are having the same value (just a guess?) why not move the textbox outside the tabpage so that you don't need multiple versions? Now a suggestion: as you loop through the Controls array, you can check each control name (a string) against the name you're looking for. If it matches, you have your index. Don't forget that if you your textbox is in a groupbox on a tabpage, you'll have to look in the TabPage's Controls collection to find the groupbox, then loop through that control's Controls collection. You may just want a recursive loop. One more suggestion: If you DO know the control by name, such as txtDueDate1, you can bind the text of that control to the text property of another control. For example, suppose you have textBox1 and textBox2 and you want to keep textBox2 in sync with textBox1. You can use this line of code in Form_Load (or wherever you want): // The first "Text" is the Text property on textBox2, the property you're binding // the second "Text" is the property on textBox1 that you want to bind from textBox2.DataBindings.Add("Text", textBox1, "Text"); -Nerseus
-
Don't forget to use: GraphicsFun.Dispose() after your call to DrawImage(). You must Dispose of the Graphics objects that you create yourself through CreateGraphics(). If you use the Graphics object provided through a Paint event, you do NOT want to call Dispose(). -Nerseus
-
Actually, if you're bound to a DataSet, the DataSet contains the original values as well as the current ones. Maybe that will work for you? As for the logged in user, I hope you're storing THAT in a variable somewhere... right? :) -Nerseus
-
Microsoft is providing a 4-part series on migrating from VB6 to .NET, concentrating on WinForms applications (windows, not web). There is also another 2-part series covering general migration issues. Here are the first four segments (WinForm migration): Part 1 (already happened) Part 2 (March 17) Part 3 (March 18) Part 4 (March 19) And the final two segments (general migration): Part 1 (March 20) Part 1 (March 21) Click here for a list of all free upcoming webcasts, or click here for a list of previous webcasts. -Nerseus
-
Here's what I use, more or less... First, I defined a color structure that I know matches my bitmap. You can define several structs and pick the best one based on your bitmap's format (get the information through the surface description). Here's the struct: public struct ColorType { public byte b; public byte g; public byte r; public byte a; public ColorType(byte r, byte g, byte b) { this.r = r; this.g = g; this.b = b; this.a = 255; } public ColorType(Color c) { this.r = c.R; this.g = c.G; this.b = c.B; this.a = c.A; } } Next comes the locking, changing color bits code. This is used in a Ms Pacman clone. The bitmap holds one set of greyscale ghost images. Each ghost's colors are changed dynamically at runtime by modifying the surface bits. private void FixGhostTexture() { // textureOrig is the original greyscale image. SurfaceDescription desc; desc = textureOrig.GetLevelDescription(0); Texture textureCopy = new Texture(dev, desc.Width, desc.Height, 1, 0, desc.Format, Pool.Managed); Surface dst = textureCopy.GetSurfaceLevel(0); Surface src = textureOrig.GetSurfaceLevel(0); SurfaceLoader.FromSurface(dst, src, Filter.None, 0); desc = textureOrig.GetLevelDescription(0); // Get the bits for the surface and re-color them ColorType[] c = (ColorType[])dst.LockRectangle(typeof(ColorType), LockFlags.None, desc.Width * desc.Height); ColorType c1; switch(ghost.Type) { case GhostType.Red: c1 = new ColorType(Color.Red); break; case GhostType.Blue: c1 = new ColorType(Color.LightBlue); break; case GhostType.Orange: c1 = new ColorType(Color.Orange); break; default : c1 = new ColorType(Color.Pink); break; } // hard-code offsets of 56 and 96 because this UI class knows where the sprite lives in the bitmap for(int y=56; y<56+Ghost.GhostPixelHeight; y++) { for(int x=96; x<96+(Ghost.GhostPixelWidth * 2); x++) { // The ghost consists of two colors, either all white (255, 255, 255) // or all black(0, 0, 0). By checking the first byte, we // know which color this pixel is and can choose the appropriate // new color. // Note that the pixels are stored in BGRA format (A is for Alpha) if(c[y * desc.Width + x].r==255) { c[y * 256 + x] = c1; } } // for x } // for y dst.UnlockRectangle(); sprGhost.Texture = textureCopy; } Inside your loop, using my sample above, you could change any parts of c[] that you want. To change the first pixel to red, you could use: c[0].r = 255; c[1].g = 0; c[2].b = 0; c[3].a = 255; Since I'm only changing the white pixels to a known color (whatever color ghost this is for), I can predefine a ColorType struct variable (c1 above) and use that for every white pixel. Remember that structs are copied by value, classes are assigned byref. So using "c[y * 256 + x] = c1;" copies every value in c1 to c[y*256+x]. Also, you know longer have to worry about the "pitch" of the texture. Video card memory may have to pad the width by a few bytes to get it aligned right. From what MS says (and what I've seen), the locking/unlocking takes care of the pitch vs. width issue for you. If you haven't already, run dbmon.exe (I think it's called) before you run your program in the IDE. It spits out a ton of good messages every time you use DX9. In particular, I had to make a number of goes at loading my textures in the right pool with the right usage (and similar guesses on the locking flags) before I got it to work right for my video card. The messages were fairly clear, things like "You must put your surface in Managed Memory to lock the surface" (not right at all, but you get the point). Good luck! -Nerseus
-
You can set the form's Cursor property to Cursors.None (I think). _ner
-
Your update is not inserting, it is updating every row. I would guess that you have no WHERE clause on your UPDATE, and hence it affects every row. To know why, we'd have to see the code that does the UPDATE. -Ner
-
You must use INSERT. -Nerseus
-
Can you not maximize the form? -Nerseus