Answer Questions
rravech Custom Event Handlers and Event Args for ToolStripButton Control - STUCK!
Hello. I'm stuck. I'm trying to use the menustrip control as a psuedo start menu. I'm populating the menu by reading an xml file which works fine. Where I'm stuck is that the built-in "Click" handler for the ToolStripButton only passes the Text stored on the ToolStripButton in EventArgs. I need to also pass a string holding the path of the item. I'm trying to inherit the ToolStripButton class into my own custom class that holds the path, and uses a custom handler and custom EventArgs. This is my first attempt at anything like this, so if it's wacky, please advise on the proper way to "handle" (no pun intended) it: My Custom Button Class: ********************************************************* class iLaunchMenuButton:ToolStripButton { ...Show All
Adrien Regimbald general Array
I'm looking for a way to determine the numbers in an array. I am basically creating a string array then using a string with multiple words from a text box to split into that array. Only problem is i cant tell whow many items are in the array, to determine how to manipulate the different strings. Anyone understand this let alone how to solve the problem Thanks Thomas You can use the Split method of the String class to split a string into an array: string[] words; words = TextBox1.Text.Split(); You can then use the Length method of the Array class to determine how many items: MessageBox.Show( words.Length.ToString() ); Use a generic list strin ...Show All
Leo Fi How do I open a second form????
Hey guys, I would appreciate any help you all can give me. I have TWO forms, Form1 and Form2. Form1 is associated with form1.cs and Form2 is associated with Form2.cs. How can I open up Form2 from a button on Form1 I came across some code that allows me to create a new form out of the blue and open it, but it's not really helping me. I want to open the form I created on Form2.cs. Any ideas what I'm doing wrong Thanks guys... Todd Hi James, thanks for responding. I am fairly new to C#. I come from a Delphi background. In Delphi, I would add the Form2 "Unit" in my uses clause at the top of my code. I would then be able to access that object and display or close the additional form that I made reference ...Show All
mlawton Windows Services
Hi. We want to install two instances of the same windows service. We have already installed the first one but when we can't install the second one. What should we change in the setup project to allow the second installation Thanks a lot. As far as your installation issues go it is probably a problem with ordering in your installation and the fact that the service name as provided by the service doesn't match the installer. You must ensure that the installer uses the same service name as the service itself. If you use the recommendation that I made earlier about using a static property then this is a no brainer. As for the UI you can definitely prompt the user for the service name during installatio ...Show All
sakya IDE freezes for 5-10 seconds when saving a file
I recently replaced my motherboard, and since then saving files in Visual Studio "freezes" the IDE for 5-10+ seconds. It displays the animating save icon in the status bar, but doesn't respond to keyboard or mouse input, and doesn't repaint if I move another window over it, until the save is done. This also happens every 5 minutes when Visual Studio auto-saves recovery information. I'm not certain where the problem is - if it's with Visual Studio, the drivers for the disk controller, or the hardware, but since I haven't experienced anything similar in any other application, I figured I'd ask here. In case it's important, my new motherboard is an: ASUS A8N-SLI Premium Socket 939 NVIDIA nForce4 SLI ATX AMD Thanks. ...Show All
FastRider30 Test conversion of System types
Is there a way to see if an object can be converted into a specific System type without using a try catch mechanism public void convert ( object o) { try { DateTime date = Convert.ToDateTime( o); } catch (Exception ex) { MessageBox.Show( ex.Message); //Can't convert to datetime for example. } } Is there a way to just check to see if it can convert, avoiding the use of try n catch. not really I don't think, look at the docs about to see what type the object can be converted from. In .NET 2.0 there are some tryparse methods (Int.TryParse, DateTime.TryParse) which returns a bool indicating a success or not and if so, the result output given to the TryParse() method is stored. In yo ...Show All
Nils VG How do I convert a 4-byte array (of type bytes) into a 4-byte floating-point?
Okay, how do I convert an array of bytes into the 4-byte floating-point number with the same binary representation What I'm trying to do is, that when I loaded a binary file into memory, I want to be able to set the four bytes of a byte array to some values, and then retrieve the value in floating-point. In C++, this would've been rather easy using pointers, as shown : char buffer[4]; // Set some values to this buffer float* fp = (float*)buffer; // Access the 4-byte array as a floating point cout << "Floating point value : " << *fp << endl; // Print it Now how do I do this without pointers Don't tell me to try to load the floating-points directly from the file, by using some function like ReadDWord. A ...Show All
Shadi Mari How to write Debug directive in CS file?
In aspx file, it is written as "<%@ Page Language=C# Debug="True">". In CS file, how to write it. My purpose is to get a pdb file after compilation of the cs file into dll file, so that I might trace the line number once some errors occur in web application. Thks a lot! in ASP.NET it is done by web.config file. You can specify debug version like this < system.web > < compilation defaultLanguage ="c#" debug ="true" > </ compilation > </ system.web > and release like this < system.web > < compilation defaultLanguage ="c#" debug ="false" > </ compilation > < ...Show All
guyinkalamazoo3 Webbrowser - Find what word was clicked
Is it possible to find what word a user clicks when he/she clicks inside of a webbrowser control, using C# I would like to highlight/select the word that is clicked, or at least know what the word is, so I can search my database for possible definitions. I would like it to be like when you double click a word in internet explorer (on a webpage), and it selects the word, but I only want the user to have to do it in one click. I thought about converting all my words to hyper-links, and then getting the active element from the Document, but I think that will take too much processing power for lengthy data displays. Any ideas will be helpful. Thanks, - Jon There recently was a subject covered on handl ...Show All
Norb Buttons/TextBox/Integers
Thank you for you response in advance. I am making a Windows application that will ask the user to enter their security code. They have to use the buttons that are on the windows app. Their code is a four digit code. I have tried several ways to get the four digit number to appear but everytime I click a button the new number appears and the old disappears. I tried to convert the int to a string and then append it to the textbox and to what was already in the textbox. This is what I tried: private void numberOne_Click(system args bladdy blah) int numberOne = 1; string num1 = Convert.ToString(numberOne); codeBox.Text = Append.(num1).codeBox.Text: //append the 1 to whatever is already there. ...Show All
Simon Dahlbacka Exception when retrieving binary data from Sql Server Db
Hello I am trying to read binary data (avi file) from a Sql Server database. The problem is I always get an exception: Index was outside the bounds of the array. FileStream fs; BinaryWriter bw; int bufferSize = 100; byte [] outbyte = new byte [bufferSize]; long retval; long startIndex = 0; SqlCommand getVid = new SqlCommand ( "SELECT Data FROM Mediafiles WHERE Filename='test.avi'" , connection); connection.Open(); SqlDataReader myReader = getVid.ExecuteReader( CommandBehavior .SequentialAccess); string path = Path .GetTempFileName(); while (myReader.Read()) { // Create a file to hold the output. fs = new FileStream (path, FileMode .OpenOrCreate, FileAccess .Write); bw = ...Show All
Jeremy Jarrell Invoking windows application from web application
Can I open an windows application from web application. If you want to run the windows application server side, just use Process.Start to start the application you want. ...Show All
ahmedilyas report logging
hey guys, i'm relatively new to c# and i've got a important project using c#.. why blame my school.. anyway, the project i'm working on, involves the saving of Logs.. for reference.. however, these logs only store 1 entry at any given time. should there be more than one user accessing the database at one time, it might cause the system to crash. it'll be so darn helpful if anyone can tell me what method i should do and stuff. or perhaps a certain phrase i can use to search up on relevant information. i'm in need of help badly.. thanks in advance. you can probably easily create the methods to insert data into the database.... create a method that splits the entries into fields by the comma seperator for exam ...Show All
GlitchEnzo Windows Service OnStart Event
Hello Everybody I wanted to know how to work with Windows services In the Service it is said that we should not write looping code in the OnStart Event So where should i write my code of looping event as such i wrote in the start event it works fine Is it good to write the code in onstart as my code will take a time may be more than 30min to 1 hr And one more thing how to stop the service i.e after my code has done the work Thank you in advance Sarguna, The OnStart event handler is not intended to contain the service's 'work' code. Instead try moving your looping code to a function that follows the WaitCallback delegate definition and call ThreadPool.QueueUserWorkItem in the OnStart event. This will allow the OnStart event ha ...Show All
kenny125 very odd enum behavior
Given the following enum declaration: [ Flags ] public enum HidableElements : uint { All = uint .MaxValue, // (2^32)-1 Equipment = All, // (2^32)-1 MaterialType = (2^7), // 128 Module = (2^6) | Slot | Component, // 124 Slot = (2^5) | Material, // 48 Material = (2^4), // 16 Component = (2^3) | ComponentParameter, // 12 ComponentParameter = (2^2), // 4 ControlJob = (2^1) | ProcessJob, // 3 ProcessJob = (2^0), // 1 None = 0, // 0 } when I compile this and look at what ends up in the assembly (Reflector.NET), I see this: [ Flags ] public enum HidableElements : uint { All = 0xffffffff , Component ...Show All
