In my form, I'm adding new records in the datagridview. However, for some reason only the first column of that datagridview is updated. Then I tried to clear out the other codes and left the code for the datagridview. Apparently, I failed. Then I tried creating a new form with the same design and code. And it works out pretty well.
I have 3 Windows Form: frmMain, frmFirstForm, and frmSecondForm.
frmMain is the form that will load when the application is started with 2 tabs to access frmFirstForm and frmSecondForm.
Here's my problem:
After making a selection from a combobox on frmFirstForm, I would like a datagridview header to change based on the selection made. Here is a list of items on one combobox: Item1, Item2, Item3, Item4. When somebody chooses Item one, the header on the datagridview on frmSecondForm should display: JohnItem1, PaulItem1, BradItem1 and so on. Those items are not part of the comboboxes, but they will be shown as header text on the datagridview on the second form either automatically or after clicking OK from frmMain. There's no OK button on frmFirstForm, but on frmMain.
The only code I have right now is the if statement on the form load on frmSecondForm. Here's what I have:
private void HeaderTextLoad() { if(comboboxonfirstform.text = "Item1") { datagridview1.Columns[0].HeaderText = "ItemJohn"; datagridview1.Columns[1].HeaderText = "ItemPaul"; ... And so on. } }
I have a button click that is adding user input into a datagrid view. I am trying to add the information into a row, but the way I am trying is giving me an error. Is there a better way to do this?
I have 2 datagridview in one windows form, When I click row from datagridview1, it shows in datagridview2 (Select *from....). Also I have combobox column in datagridview2. My question is, when I select items in combobox, and click to new row in datagridview 1, datagridview2 combobox's is getting empty. it is my code:
private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) { try { int id = Convert.ToInt32 (dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value);//3
I have a non form class. I want to update label/ check status of check box etc.. in non form class ( here resides functions that contains logic). How can i do that ?
This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.
So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.
When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.
Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.
What's the best way to do this, at the moment i'm creating the Form2 instance like so:
//.... //Detect the Login form being closed loginForm.Closed += new EventHandler(OnLoginClosed); //... //Open the main form when the login is closed private void OnLoginClosed(object sender, EventArgs e)
[Code] .....
This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.
I have a form with 2 text boxes (Email and Password)
The user fills in the text boxes and clicks on the Log in button. The code behind the log in button does the following, First connects to a table (Users) in phpmyadmin. Next runs a SQL query (SELECT * FROM `users` WHERE Email = '" + sEmail + "' AND Password = '" + sPassword + "'") sEmail being the variable created from the text entered in Email text box and the same for password.
Next if the record count == to 1 it opens up the main menu form and if the record count == 0 it fails and the user does not get to the main menu.
All of the above is fine and working however what I want to do is take over a variable from the log in form to the other forms.
The code is below for the sign in button as all my code is behind that (I think this may be where I'm going wrong).
public partial class WelcomeForm : Form{ public static string connStr = "server = localhost; " + "database = ppw5; " + "uid = James; " + "pwd = buster;";
[Code] .....
And the Main menu form where I'd like to take a variable over with me, lets assume the variable is the UserID from the database table that I pull from the dTable I created.
public partial class MenuForm : Form { //Call the CloseProgram class and create a new method called ClassClose. CloseProgram ClassClose = new CloseProgram(); WelcomeForm User = new WelcomeForm(); public MenuForm() { InitializeComponent();
I have a program which when a button is clicked on Form1 it runs a vision system operation on an image in a window on a Form1. There are also other buttons on the Form1 which can change things like threshold levels so the inspection can be run again with different settings. It all works fine but I want to change it to remove the buttons from Form1 so that when the user clicks on a button on Form1 it opens up another form, Form2, and all the buttons which were on Form1 are now on Form2 and the image analysis should run on Form1 when the buttons are used on Form2. I have taken over all the code from Form1 to Form2 and I'm trying to make this happen by creating a new oject on Form1 which calls a method on Form2 which contains the code which was in Form1 and called when the button was clicked on Form1 - not working!! I have a constructor in Form2 but I think I have become monumentally confused.
This was the code which was on Form1 when the inspection button was clicked.
Is there a way to indicate how many records exist in a given file? For example, vectors have the vector.size() command to show the number of given elements. Is there a such command for files and records?
Is this the right codes for deleting a recoed on the text file.
void dlte(){ string line, recorddate; cout << "Please Enter the date of record you want to delete: "; cin >> recorddate; ifstream myfile; ofstream temp; myfile.open("herald.txt");
I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. So, i have this, but
1) it doesn't let me enter more than 1 id, and 2) it doesn't output anything to my output.txt.
records.txt 6 123 Jose Garcia 99 345 Luis Garcia 87 234 Jazlyn Soriano 79 456 Carter Sander 95 567 Natalia Soto 67 789 Isabel Santana 80
#include <iostream> #include <fstream> #include <cstdlib> #include <string> using namespace std; class Student { private: int id;
I've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...
what I need to do is load a dataset with the most recent record for each item in the database table. Each item has an ID, location ID and date along with some numeric data. the item ID, location ID, and date is referenced in each record of the table. So each item will have multiple records with different dates that could be anything. To make things worse there may be the same item in multiple locations. and each locations items most recent record needs to loaded in to the dateset and then displayed in a data grid. At a later time there will be a location sort as well so only items in a particular location or group of locations will be loaded. More question on the data grid to come.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
[Code]....
I have driver table this is my fields as following DriverID INT DriverName nvarchar50 Nationality nvarchar50 Address nvarchar50 I have form driver have 4 texbox textbox1 DriverID textbox2 DriverName textbox3 Nationality textbox4 address this table have two records
when i press buton next (NextBtn_Click)to go third record it not accept I need next button increase by 1 if record not exist and update this in table How i do this example if i have two records
1 aln american newyork 2 adam british british
when i press next button it ok work in records exist but when i press next button to third record it not accept why what i need is when press next after 2 it come 3 in text box driver id and update this number in table
I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. I have this, but 1) it doesn't let me enter more than 1 id, and 2 it doesnt output anything to my output.txt.
records.txt 6 123 Jose Garcia 99 345 Luis Garcia 87 234 Jazlyn Soriano 79 456 Carter Sander 95 567 Natalia Soto 67 789 Isabel Santana 80
Code: #include <iostream> #include <fstream> #include <cstdlib> #include <string> using namespace std; class Student { private: int id; string firstName;
My size of binary file is 1920 KB and my struct size is 124 kb. now to find number of records in file I divided 1920/124 and it gives me 15.4.... do I add 1 to 15.4 and make it 16 or do i take it as 15?
im doing a program to store name, age, time and fitness. and i need to hold a table of 5 such records.can i do this?
#include <iostream> using namespace std; int name1, age1, time1, fitness1; int name2, age2, time2, fitness2; int name3, age3, time3, fitness3; int name4, age4, time4, fitness4; int name5, age5, time5, fitness5;
I have got 4 radio buttons on my form and & i am trying to match the text for these radiobuttons with a record in one of the database tables. Essentially I would like when the submit button is clicked to match if the selected or clicked radiobutton Text with a database record. And if this matches a messagebox to be displayed saying "match" and if not matched the messagebox should show "no match found"
in this case the "Emp_1" is the matching record , when I run my project when other options or radio buttons are clicked it executes the messageBox showing that it matches even if its not a matching record. What I am trying to say is that it does not execute the else {MessageBox.Show("no match found");} when records don't match.
i have this program that i am undertaking.....this project needs to store customer details, edit them and delete them...now i am facing the problem of deriving a code to edit those details...
MY CODE
HTML Code: #include <fstream> #include <iostream> #include <string> using namespace std; int main () { int choice [1]; string name;