Jump to content
Xtreme .Net Talk

Cags

Avatar/Signature
  • Posts

    699
  • Joined

  • Last visited

Everything posted by Cags

  1. I'm not entirely sure what you mean when you say?
  2. You can't dynamically create a method for each one. What you should be doing is creating a generic sub that will deal with all buttons, you will then attach that sub as the event for each one. The assuming you use an overload similar to the standard .Net Framework ones, you can find out exactly which button has called the event, and then filter what todo for that button using either a switch statement or whatever.
  3. Doing what you describe is not actually possible as far as I know. You say you have looked at dynamically creating controls and in my opinion that the answer to your problem. Since reference's to each Textbox is being stored in an array I would be assuming you will never need to actually access the object without accessing it through the array, as such the name of the object is kind of irrelevant, however something like this my work for you. Dim colCount As Integer = 9 Dim rowCount As Integer = 9 Dim index As Integer = 0 Dim grid(colCount, rowCount) As TextBox For i As Integer = 0 To colCount For j As Integer = 0 To rowCount Dim txtTemp As New TextBox txtTemp.Name = "txtBox" & index.ToString() grid(i, j) = txtTemp index += 1 Next Next
  4. To the best of my knowledge this isn't possible. You would be better off having a single function for all menu's that has a switch statement based on the menu name.
  5. Perhaps this page will help.... I think you will have to sign up to download the sample, but its free and they don't bother you with spam or anything. http://www.codeproject.com/dotnet/BinaryAndHexConversions.asp
  6. I would imagine that the problem is being caused by the 'Erase' statement. I don't know VB that well, but its the only line that seems like it could cause the error, try ReDim'ing the array after Erasing it.
  7. Before I start, can I just point out that in the comments at the top of the page you say that VB doesn't store a string as an array of chars. Is this left over from before the port, becuase a string has a .Chars property that allows you access the char at a specific index. It would have helped if you had said exactly which line throws the error. Since the code runs once without errors it seems apparent that an object is being disposed of the first time you run the function and not being re-initialised the second time you run. Without knowing which lines throws the error I can't tell which object is causing the problem. All I can say is after a cursary look at your code I couldn't spot anything obvious.
  8. Assumably the code you say is 'function that draws the array' is inside of a loop? From the code you posted, you always seem to change the last object in the array and then add it to your form, since this is the case the other objects in the array are never actually initialised, thus looping through the pictureArray will fail as the other objects don't exist. This means that whilst your form has all 100 PictureBoxes present and correct the pictureArray only contains the last one created. You will need todo something like this when you create the array. Dim pictureArray(100) As PictureBox ' loop 100 times in order to create 100 objects For i As Integer = 0 To 99 ' create an object that we will later add to the array Dim curPicture As New PictureBox ' set the objects properties curPicture.Left = 114 + locationleft curPicture.Top = 25 + locationtop curPicture.Width = 9 curPicture.Height = 9 curPicture.Image = Image.FromFile("ball.jpg") ' add the object to the array pictureArray(i) = curPicture Next ' add the array to the forms control collection so people can see the pictureboxes Me.Controls.AddRange(pictureArray) This will ensure that both the pictureArray and the Controls collection contain 100 references to the same objects. Now anything you do to the pictureArray should be reflected in the Controls collection.
  9. This is true the entire assembly would still be loaded, as (as far as I know) its impossible to search for classes in an assembly without loading it. However it does mean the resource intensive objects do not need to be created untill they are required.
  10. If you post a sample project I can have a look for you (or send it to me), but I can't see anything that is inherantly wrong with the code posted.
  11. Ok, sorry, my bad, I went back to your first post and I now see what you were doing. When you say it *thinks* the controls are in the right place, I assume you mean that whenever you look at the location property it reports the right position, regardless of the fact it appears to be in the wrong place? If this is the case I would ask if you have overriden any of the paint events for the usercontrol, as it sounds like a drawing issue rather than a positioning one.
  12. The way i've done this in the past is with a 2 tiered plug-in system (I think theres posts about it somewhere on the forums. Basically for each plugin you want you will have two classes the main class and a descriptor class, which will contain information such as name, possibly an icon, and a method for creating an instance of the main class. Then you load the descriptor classes with your plugin controller, allowing you to display them in a list. Then you can use the create method of each class to create an instance of the main plugin object.
  13. I've had a quick look at your code and theres one thing that confuses me, in the switch statement you seem to refer to case 1 as being the first control, wheras technically the first control in a control collection is in position 0. For example you say in your comments change the first control to green, then infact change the second one. But then you go on to change the second controls position to equal the first, I guess I'm just confused about what exactly is going on.
  14. I cannot replicate this behavious either, what do you get if you use Double.Parse(s);
  15. Interesting, it will be very hard to help much without seeing the code though. If you could post the helper method in question that would be very helpfull.
  16. I'm not sure which language you are talking about specifically when you compare a for loop to a for each loop, perhaps you are simply refering to the framework as a whole. I have however read somewhere (can't remember where it might not be completely accurate) that the comparison you gave is antiquitated and infact there is currently very little performance difference between the two loop methods. Sorry this is getting abit off topic, but I think we solved the thread starters problem so hopefully this isn't too much of an issue.
  17. Assuming PictureArray is of length 100 then the code you have provided basically says "for i equals 99 to i equals 100", so it would only detect the collision if you hit object 99 or 100 (which in theory should cause an error if its an array of 100, because 100 would be an out of bounds index). marble_eaters example was perfect and I cannot see why you have got an error with it the only thing I can assume is that there is some confusion somewhere.
  18. The way I would do it is rather than inheriting from a base class use an Interface, then you create each employee type as a plugin (theres an excellent plugin example in the tutors corner). You could probably still do the plugin approach using a base class, but as i've never attempted this and as such I couldn't say much more. The basic idea is that a plugin controller will load a list of each available employee type. You can then use the SelectedIndex value of the combobox to create an object of that type.
  19. I'm personally of mixed opinion about this. Understanding what goes on 'behind the scenes' can certainly be important at times, but I also feel that many many programmers out there really don't need to understand these details. Things such as the Handles keyword basically embody the idea of encapsulation, allowing developers to use the feature without really needing to worry whats actually going on in the background. In my opinion its just another step towards making programming languages more accessible to new programmers.
  20. I think you might be confusing people with your description. You keeping talking about a datagrid, but if I'm understanding you correctly then what you are after isn't supported in a standard datagrid (as far as I know). It sounds to me like what your after is a hybrid of a datagrid and a treeview (thus allowing child nodes, as well as multiple columns). Perhaps one of the standard controls can achieve this, but if they can I've never come across it.
  21. I'm no expert programmer and I'm definately not a c++ expert (closest I've been to it is looking at it a few times at uni). But your comment of "but how can i reach the members of the parent in a different way" intruiged me. If all you need to do is access members from the opposite form, then (in c# at least) you could simply pass a reference into the constructor of the other form. This shouldn't cause a circular dependency problem as one of the objects will definately be created before the other, passing a reference to itself to the other form.
  22. I'd have to agree with much of what marble_eater suggested. When I started programming I often found that I would have multiple boolean states but only one of them could be true at once, as such all the booleans could be replaced with a state enum.
  23. True, there are several valid overloads, I'm just used to using the Compact Framework, which is very restrictive.
  24. Just so nobody gets confused its not strictly neccessary to alter behaviour for a textbox unless you don't want the form to perform the action when it is focused. Text typed will still appear in the textbox it was just also call the forms keypress. As such if the forms key press only handles shortcut keys and such, you will not need to code special cases for your textboxes.
  25. button1.Font = new Font(button1.Font.Name, button1.Font.Size, FontStyle.Bold);
×
×
  • Create New...