
Bucky
*Experts*
-
Posts
803 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Bucky
-
The ItemCheckEventArgs passed to the event handler has an Index property which conatains the Index of the item. Private Sub lvwAppt_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles lvwAppt.ItemCheck Dim itemIndex As Integer = e.Index ' itemIndex is the index of the item being changed End Sub
-
I looked into the new modifier, but it seems that it can only be used on a method that hides another method with the same parameters. In this case, however, the methods have different parameters, so it won't work.
-
No, the words do not have to be fixed length. If you put one word on each line in the file, then you can create a StreamReader to read the FileStream, use its ReadLine method to read the stream one line at a time, and for each line add that text to the ArrayList. In this example, fs represents your FileStream. StreamReader sr = new StreamReader(fs); string s = sr.ReadLine(); while (s != null) { // do something with the word s s = sr.ReadLine() }
-
Dim command As String = "ping 192.168.1.1" System.Diagnostics.Process.Start(command)
-
How do I hide a base class member (a method in this case) so that only the member of the inherited class can be used, even if the members are of different types and have different parameters? Take the following example: public class BaseClass { public string Moo() { return "Base class moo!"; } } public class InheritedClass : BaseClass { public string Moo(string text) { return "Inherited class moo! - " + text; } } As you can see, the InheritedClass.Moo() method will overload the Moo method for that class. But how can I make it so that the inherited method overrides the base method, even though they have different parameters? This can be accomplished in VB.NET with the Shadows modifier, but what is the C# equivalent?
-
When you inherit from a class such as CollectionBase, you do not need to override every single member like you need to do when implementing an interface. For example, the Clear method of the base class will clear the List collection, so you don't need to override it, unless you want to add some extra functionality. ToString could return whatever you want it to... it could be a string representing the class's type, or it could be a delimited string returning all the elements in the collection, for example. GetType simply returns your class's type... As far as I can tell, it can't be overriden (in VB.NET at least, since GetType is a keyword). For the Equals function, compare each element in the collection passed to it to return a true value if everything matches up. Otherwise, return false. Again, the base class probably will handle this just fine. The same holds true for GetHashCode, and any other method you're not sure of; if you don't know what to put, then let the base class deal with it. Although I'm sure someone here will follow up with some better ideas for the overrides... :)
-
To get the text of a textbox, use its Text property: Dim mailto As String = myTextBoxName.Text You may not want this code in the page's load event, because (I think) the text of the TextBox will be its default when the page loads. It makes more sense to have this code in the Click event of a button, or something similar.
-
In addition to adding it your toolbox, you also need to add a reference to the control in your project's references. Go to the Project menu, then Add Reference. Select the COM tab, and look for the control on the list or click Browse to find the DLL.
-
Populating a datagrid with dateTime columns
Bucky
replied to LostProgrammer's topic in Database / XML / Reporting
Try setting the DataColumn's DataType property to the type of a DateTime: ds.Columns("whatever").DataType = Type.GetType("System.DateTime") -
I'm not sure I understand what you mean to "load" the control on to the GroupBox. To add a control to a GroupBox, create a control, set its properties, and then add it to the GroupBox's Controls collection. Dim newTextBox As New TextBox() ' Set the newTextBox's size, text, and position properties here theGroupBox.Controls.Add(newTextBox)
-
You're not getting the .NET version!? *gasp*
-
Reading only part of a file in between string markers.
Bucky
replied to aewarnick's topic in Directory / File IO / Registry
Yes, or you could Serialize a class to and from XML, and then all you'd need to do is access the class members. Or you could create an XML Schema and then load and save the XML through a DataSet. The possibilities are endless. If you're looking to save and load program settings, or something similar, Serialization is the way to go. -
The MessageBox class is also a member of the Windows Forms namespace. When you're using a Web application, the only way to show a popup message box is to use client-side JavaScript or VBScript, and using the alert() or confirm() functions.
-
The ToTitleCase function of the TextInfo class can be used to convert a string to Title Case (aka Proper Case), as so: Dim cinfo As New Globalization.CultureInfo("en-US") m_strFirstName = cinfo.TextInfo.ToTitleCase(m_strFirstName)
-
When setting the DataView's Sort property, you may need to specify whether to sort ASCending or DESCending. cmf.Sort = "S_COD ASC"
-
To get or set the selected item in the ListBox control, use its SelectedItem property. The Object Browser is an invaluable tool for looking up class members; I use it all the time.
-
The .NET Framework provides classes for serializing data to and from XML. If store all your application's settings in one class, then you should have no problem creating XML files to store and retrieve the settings. XML serialization is the .NET equivalent of INI files. There are some good explanations and code samples in the help collection. For starters, check out the XmlSerializer class and the Serializable attribute.
-
That's a good question, and I'm not exactly sure what the ShowDialog is doing. I think it may be allowing more processing time to other applications, in which case you can do the same thing by calling Application.DoEvents() to allow other apps and the OS to complete some commands. This may allow Windows sufficient time to free up the bitmap so you can save to it.
-
Sure it's still there... right-click on the project in the Solution Explorer, then click properties. There is a dropdown called "Startup object" under Common Properties -> General.
-
I'm afraid I don't know how to go about this, sorry. I was hoping it was something simple that I mentioned that would help. :) Maybe someone else can pick this up...
-
I'm not sure I understan what you're trying to do with all that rambling... :) The HttpWebRequest has a CookieContainer property that lets you retrieve the cookies associated with the request. The HttpWebResponse has a Cookies collection which does the same thing, only for the web response. You could also use the request's Headers collection and find the get-cookie one (or whatever the response cookie header is called). To set a cookie, just send a response in a HttpWebResponse's Headers collection, with Set-Cookie and the cookie values. Does that help?
-
Great minds think alike! I can't believe we both reccomended the same thing... wow.
-
It depends on what control you want the user to press enter on. If it's the form, add code in the Form's KeyDown or KeyPress event handler. If it's for a textbox, then add the code for THOSE event handlers. You can have multiple controls call the same event handler if you want, too. Another thing you can do is to set the form's AcceptButton property to the button that you want to call when the user hits enter. Then the user can click that button OR hit enter, and whatever code is in that button's click event handler will be called. [edit] I forgot to mention... the KeyChar you're looking for in the KeyPress event is the Carriage Return character, ControlChars.Cr [/edit]
-
How about the IsSelected function? :)
-
I don't understand what you mean. The CancelButton property of a form closes that form and returns a DialogResult of Cancel if that form is shown by using ShowDialog. If you want code to be run when this button is clicked, just add code in its Click event handler. The InputBox function (which is from VB6 and shouldn't be used) only returns a String, so I'm not sure where the CancelButton comes into play here. You can check if the return string is empty to see if the user pressed Cancel, if that's what you mean.