Hi, I have a DataGridView control on a POS application I am writing as a project. I am having issues when trying to remove certain items from the control. Below is an example :- 1 Item 1 $5.00 -Extra 1 -Extra 2 1 Item 2 $10.00 1 Item 3 $2.00 -Extra 1 I want the user to be able to click on an item (or extra) in the datagridview and delete it. I can do this for single items and extras and it works perfectly (using removeat)but when I select an item, I want to check if there are any "extras" associated with the item and remove them aswell. Extras are always immediately below the item in question. My stumbling point seems to be when I remove 1 using RemoveAt, the index numbers change and I get exceptions. This datagridview is not bound to any datasource and I am creating it on the fly. Any help with the logic would be muchly appreciated. Thanks, Daniel.
User 3678645
Posts
-
DataGridView and Deleting Rows -
DataGridView and On Screen KeyboardHi All, Im developing a POS application as part of a personal project. The project has a Datagridview which has the items being sold (Quantity,Item Name, Price etc). The Datagridview is on the left of the screen and on the bottom right is my virtual keypad which is basically just a series of Buttons, one for each number. The rest of teh screen is made up of various buttons indicating stock items to sell. Im having problems getting my head around how to modify a value in the datagrid using the on screen Keyboard. If I click on the button wont focus be taken away from teh Datgridview cell i want to edit? For example I want the user to click in the Quantity Row on the datgrid and it selects (highlights) what is currently in there (1 For Example) and then if I hit the "2" Button it replaces the 1 with a 2. Any assistance would be greatly appreciated. Thanks, Daniel.
-
Thread PerformanceHi All, Im hoping someone can give me an idea on what I may be doing wrong (if anything). In my project I have a Combo Box which I populate from a SQL Database (using a Dataset and a for statement looping through each record). I have done it on form load and it works well however I decided to run it from a background thread so I become familiar with threads and for a few other reasons. Anyway, i have done it using a Thread but I seem to have taken a very large performance hit. Without a thread, populating the combo box (on Form_Load) it takes about 1 second. With the Thread it takes about 6 seconds. Im assuming since Im new with threads there is something obvious in my code that is wrong. Here is the relevant code in question:- //Create Delegates for the Threads to Access The Forms UI private delegate void UpdateComboBox(ComboBox cboName,string strItemToAdd); Code in the Form_load Event //Hide the Status Label lblStatus.Visible = false; //Start by Enabling the Loading Circle //This is an indicator that the Background Thread is still running //The Background thread is connecting to the database and populating the Combo Boxes lblLoadingFormData.Text = "Loading Data"; lblLoadingFormData.Visible = true; lcFormData.Active = true; //Create the Thread which will Update the Combo Boxes Thread thrPopulateComboBoxes = new Thread(this.PopulateComboBoxes); thrPopulateComboBoxes.Start(); Code to Populate the Combo Box private void PopulateComboBoxes() { //This Method will Populate the ComboBoxes on the Form //Customers ArrayList al = new ArrayList(); //Customers Combo Box al = myDatabaseFunctions.PopulateComboBox("SELECT Name FROM tblCustomers ORDER BY Name ASC", "Name", "Customers"); foreach (string s in al) { this.Invoke(new UpdateComboBox(this.AddItemToComboBox),new object[] {cboCustomer,s.ToString()}); } } I know the issue is not with the Arraylist as this is the same sort of code I am using in a non thread and the performance is fine Finally the code to add to Combo Box private void AddItemToComboBox(ComboBox cboName, string strItem) { cboName.Items.Add(strItem); } Can any1 offer some thoughts as to why Im taking such a performance hit? Am I doing something wrong with the threads? Thanks in advance, Daniel.
-
Form EventsHi All, I'm having some problems finding the correct Forms event from which to fire my code. I want to run a sequence of code automatically once a form is displayed on the screen. Form_load isn't correct as my code finished before the form is displayed. Form_Shown doesn't seem to trigger consistently. Form_Activated triggers multiple times Form_Validated doesn't seem to trigger consistently. What event should i use? I basically want the code to fire as if the form was displayed on the screen and I hit a "Start Button". Thanks in advance. Daniel.
-
Client / Server DesignI was hoping someone may be able to give me some feedback on my design principles. I have done alot of applications relating to databases etc in c# but this is my first try at a Client / Server application. I wannted to check some of the recommended ways of performing client / server actions. The application is basically a front end for a database. Basically my program will consist of a server application which will have a connection to a database. When a client wants to see records from the database they send a request to the server, which in turn connects to the database, retrives the records ands sends the record data back across the network stream and the client parses the records and displays them. Does this sound like a standard and solid principle? Thanks in advance
-
TCP Socket ListeningI am trying to create an application that simply starts listening on a specific port number on the local machine, and writes all data received to a text box on the form. There will be a 3rd party application that is sending data th my IP address on a specific port number. From what ive been reading, maybe I should use a TCPListener but Im not sure where to start. Any help would be appreciated. Thanks.