698 Posted Topics
Re: There is a quirk with Math.Round. It defaults to rounding to the nearest even number, so 1.5 = 2, 2.5 = 2. If you use [iCODE]Math.Round(2.5, MidpointRounding.AwayFromZero)[/iCODE] it will round to the nearest whole number. | |
Re: You are making a lot of extra work for yourself. If you are always going to store 10 teams and each team always has 25 players then a 2D array is perfect (as kplcjl mentioned). First dimension is teams, second is players: [CODE] Label[,] teamList = new Label[10,25]; teamList[0,0] = … | |
Re: As diamond drake said, it is beyond unlikely that the colour you are looking for will appear in a single pixel on the screen. You are more likely to find a large collection of locations. Diamonddrake's suggestion of finding the area of highest saturation would be a good approach. Not … | |
Re: adatapost and SharpJohnnyG are both correct, depending on what you meant. Can you clarify your question. Are you trying to alter the text that appears above each page (eg "tabPage1") or are you trying to place text inside the tab page itself. If its the first, then what SharpJohnnyG said … | |
Re: Your problem is that you are opening the StreamWriter at the top of your code, even though you might not use it. If the file already holds a value then the streamwriter isnt used, then when it is disposed at the end of the method it saves its contents to … | |
Re: Therror messages are there to help you find the problem. I know as a novice they can be confusing, but it will help you a lot if you learn to understand what they are telling you. You said you didnt notice that you had 2SERIAL_NO instead of @SERIAL_NO, but that … | |
Re: Whats your question? You said the code adatapost gave you worked ok but havent said what elese you actually need help with :) | |
Re: My first thought was the same as jonsca's. If you want to make it impossible for the button to be clicked, set the buttons Enabled property to False. Then it doesnt matter if they can move the pmouse over them or use the keys. The button is visible but disabled … | |
Not sure if the title is the correct term for this, but i want to replicate the mailmerge style functionality in one of my apps. In other words, i would like to bind a keyword to a database field. For instance, whilst writing a description for a new stock item … | |
Re: As adatapost has said, the policy here at Daniweb is to help those who have shown effort first. To get you started, at the design stage you need to break down the problem into individual steps, then solve each of them. This is first achieved in pseudocode. You need to … | |
Re: Here you go: [CODE] private void checkBox1_CheckedChanged(object sender, EventArgs e) { textBox1.Visible = !checkBox1.Checked; } [/CODE] Each time the checkboxes checked value is changed the textboxes visible property will be set to the opposite. | |
Re: Ok, firstly, why is this a poll? It needn't be and thats probably why you have received down votes. Secondly, your question stated that "balance is calculated as opening_balance(from 1st table) + quantity_purchased(from 2nd table) - no_of_issue(from 3rd table)." Adatapost has given you the queries you need to retrieve each … | |
Re: kplcjl, your quick quiz highlights some important issues relating to inheritance and reference types. But i think someone just setting out in c# might struggle to understand the 'why' of the answers if they manage to find them at all. For the OP's benefit; classes are a reference type. When … | |
Re: Also, look at using int.TryParse rather than Parse. TryParse will copy the value to an output variable and returns a boolean value to show wether the parse succeeded. int.Parse will throw an exception if the user doesnt enter a valid number. [CODE] Console.WriteLine("Please enter which shipping method you want:"); Console.WriteLine("Enter … | |
Re: This is a common mistake amongst new coders. You must ensure that all code paths assign a value before you try to access it. As jonsca pointed out, you are assigning inside if/else statements, but if your code path doesnt fit any of your conditions then it misses all of … | |
Re: What problems are shown at the line "pictureBox1.Image = Image.FromStream(stmBLOBData,false,false);", can you give a specific error message? | |
Re: Whilst his reply may sound harsh, i have to agree with diamonddrake on this one. I enjoy helping others to learn the finer points of coding and to overcome odd/challenging problems in their code. But there is an abundance of information (both here on Daniweb and on the internet in … | |
Re: I'll second the BackgroundWorker. By running the decryption in a background worker it wont lock up your UI thread, and turning on ReportsProgress will allow you to relay the data back tou your main form to update the progress bar. | |
Re: Show us the code you have so far and we will advise on changes you can make. | |
Re: You have been asked for pseudo code, what you have posted is C# code (i use the term loosely). You need to focus on working out the flow of the program and the processes you need at each stage (ie, read in a number, store the number, sort array, find … | |
Re: The problem stems from the 'nameLast = Convert.ToString(Console.ReadLine());' being passed over/not processed on the second loop. I tracked the source down to the line in the code below. By using ReadLine isntead of Read it fixes the problem. I am not entirely sure why this is though. Perhaps someone more … | |
Re: Just to clarify, you say you want to load "images" (plural) into a picturebox (singular). What were you hoping to achieve? If you wanted to load more than one image you can use a foreach loop: [CODE]foreach (string file in Directory.GetFiles(@"C:\Pictures", "*.jpeg", SearchOption.AllDirectories)) { }[/CODE] But you would need some … | |
Re: To expand on what adatapost said, you can search the Application.OpenForms collection by name: [CODE] frmEditorAccounts Accounts = Application.OpenForms["frmEditorAccounts "] as frmEditorAccounts [/CODE] Also, depending on how you have designed your forms, you may want to alter the WindowState of the form as well as bringing it to the front … | |
Re: another way is to use if-else structure: [CODE] If e.ColumnIndex = 3 Then If Not IsNumeric(e.FormattedValue) Then DataGridView1.Rows(e.RowIndex).ErrorText = " must be a numeric value" MsgBox("Must be a numeric value") DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(3).Value = Nothing e.Cancel = True ElseIf (e.FormattedValue.ToString = "0") Then e.Cancel = True MsgBox(" must be greater than 0") … | |
Re: In this situation, i tend to make a class or struct to hold my listview items. You can either use DisplayMember and ValueMember to control what is shown and returned: [CODE] private void Form1_Load(object sender, EventArgs e) { ListBoxItem newItem = new ListBoxItem(); newItem.ID = 4; newItem.name = "Joe Bloggs"; … | |
Re: You aren't initialising an instance of the IrcBot class. You need to either make the class static if you plan to use a single instance of it or you need to create an instance to use inside your Run method: [CODE] IrcBot botInstance = new IrcBot(); [/CODE] | |
Re: Can you clarify, when you say you need 1 decimal number, do you mean you want a whole number (no '.' and no decimal value) or do you mean you wnat a number with 1 number after the '.' (a decimal with one significant figure)? | |
Re: Its not possible with the OpenFileDialog. You would probably need to roll your own control. A simple form with a listbox would do(see attached image). Code: [CODE] public partial class FileDialog : Form { public FileDialog() { InitializeComponent(); } private void FileDialog_Load(object sender, EventArgs e) { //directory to retrieve files … | |
Re: I would love to see this implemented...add an individuals group memeberships to the Community Centre, or have an optional setting to add a menu beside the current ones...or at least add email notifications to subscribed group discussions :D | |
Re: If you want to catch keyboard events without your app having focus i think you will need to use a global keyboard hook. Check out [URL="http://www.codeproject.com/KB/cs/globalhook.aspx"]this link[/URL] to get you started. | |
Re: It helps if you offer a little more information about what "THIS SORT OF THING" is. You have two button1_click event handlers there, and if i've read it right, you are displaying the password instead of checking it. | |
Re: hi, The problem is that 'user' is a sql keyword. Whilst it is syntactically possible to use keywords, it is best to avoid them. It is similar to trying to declare an variable like [iCODE]decimal decimal = 2;[/iCODE]. In C# this throws an error, in SQL it will allow it. … | |
Re: I would imagine the error is a foreign key constraint problem. Referential integrity requires that a foreign key value has a matching value in the primary key table. In other words, you cant have a contract that references a band that doesnt exist. Easiest way to overcome this would be … | |
Re: Im curious, why are you using a form? Are you trying to produce a custom pop-up? I usually use a panel which i position then show/hide rather than using a seperate form. If you use a form i think it will get focus when opened which may fire off extra … | |
Hi, I have a datagridview which displays customer orders. I have implemented a search panel with various options to narrow down the subset of orders by applying a string of filters to the bindingsource. I have also added an unbound checkbox column to allow the user to select/deselect orders along … | |
Re: Also, if your going to be trying out regex, i found [URL="http://gskinner.com/RegExr/"]this online tool[/URL] to be quite handy. Alternatively, you can download a free version of [URL="http://www.ultrapico.com/Expresso.htm"]Expresso[/URL]...great tool for putting together complex regular expressions, you can break it down into sections etc. Helped me get a handle on them :) | |
Re: have you placed those lines of code inside a method? | |
Re: Unless your application is threaded, a while loop will lock the application. Each time your form processes an event it will run [B]all[/B] code associated with that event. Any other events will wait in the message queue until the code finishes. If you have an event which contains a while … | |
Re: at the bottom of the page, just above the reply box is a link that says "Mark As Solved" :) Remember to come back if you need help with your sort | |
Re: I have been a geek for years but i hit my ultimate geekiness yesterday: i was doing rough sketches of entity relationships for a database design. Key point here; i was using good ol' pen and paper. The geeky bit was when i started a second diagram and for an … | |
Re: Hiya, Something like this: [CODE] string folderPath = @"C:\Users\Dan\Pictures"; string[] fileList = Directory.GetFiles(folderPath); foreach (string file in fileList) { //do something to file //'file' contains path as string } [/CODE] or if you want to select a folder at run time you can look at a FolderBrowserDialog rather than hardcoding … | |
Re: [CODE] while (Count <= Number) { Count = Count * Count; Console.WriteLine("{0}", Count); Count = Count + 1; }Console.Write("Give in a number..."); ulong Number = ulong.Parse(Console.ReadLine()); ulong Count = 1; while (Count <= Number) { Count = Count * Count; // <-- you're problem is here Console.WriteLine("{0}", Count); Count = … | |
Re: What ddanbe is suggesting is a more OO correct way to approach your problem. By creating a class to store the information relating to a Person you can then create an array of "People". To just store ID and Description you will need a 2-dimensional array. Since a standard array … | |
Hi Guys, Firstly, Happy New Year!! Second, here my first query of the new year: I am using a stored proceedure to retrieve records from a database that match a number of search parameters. I now want to show a subset of those records in my Datagridview. I [B]don't[/B], however, … | |
Re: First of all, unless you intend to programmatically set the selected index of the combobox, you dont need the set {} value in your property. You can create it as a read only property: [CODE] public int selectMonthIndex { get { return monthSelection.SelectedIndex; } } [/CODE] The way a property … | |
Re: You need to set TabStop = False on [B]every[/B] control in your form if you want the tab key to register in the KeyDown event. If even a single control that can receive focus has its TabStop property set to true the Tab key wont register. | |
Re: If you just wanted a rough progress, you could use [iCODE]progressBar1.Maximum = Directory.GetDirectories(rootDirectory).Length;[/iCODE] to find the number of directories to check. Then then increment the progress bar's value after each directory is checked. It wont be nearly as accurate as DdoubleD's method, but it is simpler to code and gives … | |
Re: You say the 'column' relatiesoort exists, but what is the name/index of the table in the dataset? When you use a dataset for the datasrouce you specify the table to use eg [iCODE]ComboBox1.DataSource = ds.Tables("tablename")[/iCODE] or [iCODE]ComboBox1.DataSource = ds.Tables(0)[/iCODE]. Once you have assigned the table you then set the Comboboxes … | |
Re: As ddanbe said, the policy here at Daniweb is to help those who have shown reasonable effort. You need to attemp the problem and show us what you have so far then we will offer you advice on how to proceed :) | |
Re: If you have struggled for six months you cant have looked very far...the top result from my first google search returned [URL="http://www.codeproject.com/KB/vb/InsertUpdateDeleteSearch.aspx"]this[/URL]. |
The End.