
Bucky
*Experts*
-
Posts
803 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Bucky
-
If you change the font of the Form to which you're adding the controls, then the font of any new controls that you add will be the same font as the Form. If you want to make this font the default for all projects, you need to go to the templates directory of VS and save a new project (with your changes) as a template.
-
No, there is not one that is included in the .NET framework. Since Windows Forms controls and Web Forms control are two totally separate entities, a TextBox (for example) in ASP.NET is not the same as a TextBox in a Windows app. Here is a link to a 3rd-party ASP.NET tab control: http://www.infragistics.com/products/navigation.asp?sec=2&cat=3
-
Why is XML better than just a bunch of Text files?
Bucky
replied to aewarnick's topic in Database / XML / Reporting
It all depends on what you are going to use the XML for. For storing data and program settings, XML serialization allows easy changing between a class instance and an XML file without you having to write code to parse the file. It's like an INI on steroids. For transferring data, XML proves useful because it is self- describing, that is, any client (user or app) can open up an XML file and understand its contents without having knowledge about how the file is created or how it should be accessed. If you handed someone a text file with some lines of statements, they would have no idea what each line stood for and how to handle it. Check out these two pages on W3Schools for more info: http://www.w3schools.com/xml/xml_whatis.asp http://www.w3schools.com/xml/xml_usedfor.asp -
One way to accomplish this is to load the XML file into an XmlDocument class. Then you can easily access the XML DOM and change elements and attributes, and execuce XPath statements. Here, path is a string containing the file name and path of the XML file: using System.Xml; // This belongs at the top of your code file XmlDocument doc = new XmlDocument(); string myValue; doc.Load(path); myValue = doc.ChildNodes["Name"].InnerText; Sorry if there are any syntax errors in the code, since I've only just started working with C#. This snippet should give you the general idea about how to go about what you want. [edit]Fixed up the code a little[/edit]
-
Any cryptography class that is in the .NET framework is supported by any OS that has the framework installed on it, and this includes Windows 98, ME, 2000, XP, and NT. Here is an example for ASP.NET, but it works the same for any .NET framework application, including Windows Forms apps: http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquickstart%2fhowto%2fdoc%2ffileencrypt.aspx Here is a page in the help collection that deals with cryptography: [mshelp]ms-help://MS.VSCC/MS.MSDNVS/Cpqstart/html/cpsmpnetsamples-howtocryptography.htm#cpsmpfileencryptsample[/mshelp]
-
Check out the help files for the classes within the System.Security.Cryptography namespace; there are multifarious samples for all the different types of encryption.
-
The declaration for these variables should be as follows: SqlConnection MyConnection = new SqlConnection("server=127.0.0.1;database=PictureShare;Trusted_Connection=yes"); SqlDataAdapter MySQLDataAdapter = new SqlDataAdapter(); string SessionCmd = "INSERT INTO tmPicIndex (UserID, PicName, PicDesc) VALUES ('" + user + "', '" + savename.Value + "', 0)"; SqlCommand MyCommand = new SqlCommand(SessionCmd, MyConnection);
-
The DataGrid control, which is a standard control part of Windows Forms, can be used for binding data. To insert a row at a certain index, use the InsertAt method of the DataTable containing the data. For example, this will insert the myDataRow into the first DataTable in myDataGrid to the 4th position in the rows: myDataGrid.Tables(0).Rows.InsertAt(myDataRow, 3)
-
If you're serializing and deserializing the textbox using the standard XML serialization classes, then I would think that the deserializer would handle all this for you. But to answer your question, you can use two methods of the Color class to get the color. If the string contains a number, then it must be ARGB values, and you can parse out the color value and create a color from the Color.FromArgb() method. If there aren't any numbers, then it must be a named color, and the Color.FromName() method will retrieve the correct color based on the known color name ("Red" in this case).
-
If you want to use VB code in a C# project without having to convert it all, you could compile the VB code into a class library project that you can reference from your C# project. Then you can use all the methods and properties in it just like any class.
-
You need to declare a new instance of the ASCX control, and then you can access its public variable. If you've added the control to the ASPX page, then a new instance of the control will be created at runtime automatically, so to get the variable you can just access it through the ASCX control's name. If myControl were the ASCX control, then you would use: myControl.VariableName to get and set the value.
-
Why does my hidden form cause my application to exit?
Bucky
replied to SDittmar's topic in Windows Forms
Are you using ShowDialog in a Sub Main to show your form? This sounds like the case, and if it is, you should use Application.Run to show the form instead. Then you can still hide and show it, and your program should not exit. In Sub Main: Dim myForm As New Form1() Application.Run(myForm) -
http://www.xtremedotnettalk.com/showthread.php?s=&threadid=49950
-
Count number of files in a directory
Bucky
replied to stustarz's topic in Directory / File IO / Registry
The GetFiles method of the Directory class returns an array of Strings that contain filenames, so you can just check the length of the array to get the number of files. Dim numberOfFiles As Integer Dim path As String = "c:\blah\" numberOfFiles = System.IO.Directory.GetFiles(path).Length -
How to draw line on panel from button
Bucky
replied to robbremington's topic in Graphics and Multimedia
You need to pass the Graphics class of the PaintEventArgs into your DrawLineOnPanel1 and pass it ByRef instead of ByVal, so you can modify the Graphics class directly and draw with it. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click DrawLineOnPanel1(20, 40, 60, 80, e.Graphics) 'Draw one line ' etc End Sub Public Sub DrawLineOnPanel1(ByVal inXp As Short, ByVal inYp As Short, ByVal inXd As Short, ByVal inYd As Short, ByVal g As Graphics) g.DrawLine(New Point(inXp, inYp), New Point(inXd, inYd)) End Sub In fact, since the call to the Graphics.DrawLine() method is still one line of code with the same parameters, I don't see a need for the function at all, unless you plan on putting more code in the function. Also, since the method doesn't return a value, you should declare it as a Sub instead of a Function. -
The error is not occuring the the .asax.vb code-behind file, but rather in the .asax file itself. If you switch Visual Studio to HTML view when editing the web service instead of going to code view, you should see this line at the very top (line 1). As for the error itself, I'm not sure what's causing it. Make sure that the directory is enabled as an ASP.NET application and that you also uploaded the binaries (dll files) to the correct directory.
-
I found that when the true or false keyword appears at the end of a line of C# code (with a semicolon after it), the keyword isn't highlighted: true false true; false; Also, the AddressOf operator is not highlighted in VB code tags: AddressOf
-
Before I even opened the project, I had a hunch about what was wrong, because it's a common problem that I myself have made. Since a Windows application needs to have a continuous message pump, and a window to handle it, you cannot use a simple Form.Show() to show a new instance of a form when your application starts from Sub Main. Instead, you need to tell the application to send Windows messages to a specific form. To do this, use the Application.Run() method. After the form closes (and is destroyed and its message pump destroyed), the code will return to the Sub Main and continue on the next line of code. This is what you currently have: Public Sub Main() myForm1.Show() myForm1.TextBox1.Focus() End Sub This is what you need: Public Sub Main() Application.Start(myForm1) ' Put the code to focus TextBox1 in the Form's load event End Sub The rest of the code in the module will work fine. I should point out that it is better OOP practice to shun the use of modules and instead use shared (aka static) method of classes. You may want to try this in the future.
-
How to draw line on panel from button
Bucky
replied to robbremington's topic in Graphics and Multimedia
I read somewhere that the Graphics class contained in the PaintEventArgs of a Control's Paint event cannot be accessed directly, and that you need to declare a new Graphics class and set it to the argument passed, then use THAT variable. So, your paint code should be this: 'This sub draws a line on the panel Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint Dim blackPen As New Pen(Color.Black, 3) Dim g As Graphics = e.Graphics g.DrawLine(blackPen, 50, 100, 150, 200) ' Free up memory g.Dispose() End Sub -
I downloaded and ran it and nothing of what you mentioned happened. You may want to create a new project and try again. This was one thing I noticed, however. When you are "switching" from Form1 to Form2, you need to declare a NEW instance of Form2 before you can show and hide it. This can be done in the declare (Dim myForm2 As New Form2). The same holds true for the myForm1 variable on Form2.
-
When you create each TextBox, use the AddHandler statement to add a handler for that box's Click event to some sub you have created that has the same signature as the click event. Then, when that sub is called, the sender object will contain the TextBox that was clicked, and you can cast this into a TextBox and retrieve the Tag value. This is the subroutine to handle the click events: Private Sub TextBoxes_Click(sender As Object, e As EventArgs) Dim txt As TextBox txt = DirectCast(sender, TextBox) ' Then do whatever with txt.Tag End Sub Then, to make the sub an event handler, add the following code inside the For loop of the code in Volte's post above: AddHandler txt.Click, AddressOf TextBoxes_Click And there you have it!
-
I'm not sure I understand what you mean... The whole point of PostBack being true is so that you know the user pressed a button on the form and you can act accordingly. Maybe you should be checking if PostBack is False, instead?
-
This forum has different themes than that of the ExVB forum. The themes on the ExVB forum (that have names of rocks and birds) were I believe designed by lebb.
-
How was this file created? You need to create the customer.dat file by serializing some Customers and saving that. Then you can deserialize it back into your app.
-
I think there is a problem within these lines... while(true) { customer = (Customer)bf.Deserialize(fil); alCustomer.Add(customer); } Since the loop runs while true, the loop will run forever until an error occurs. You need to provide a means to exit the loop. You could either put a try-catch statement to catch an error and exit the loop, or something similar. Perhaps you should check if customer is something other than null before adding it to the array list. If it is null, then exit the loop.