1,469 Posted Topics
Re: hi, you can try this way: [CODE] string a = textBox1.Text; string b = textBox2.Text; if (a != String.Empty && b != String.Empty) { //both ok! } else if (a == String.Empty) MessageBox.Show("Error 1"); else MessageBox.Show("Error 2"); [/CODE] | |
Re: Have you checked here? [url]http://msdn.microsoft.com/en-us/library/7a2f3ay4(v=vs.80).aspx[/url] You need to create a boolean (type of volatile) and using it, you can then stop the thread. | |
Code shows how to bind the data from a database`s table to dataTable and populate dataGridView with it. And then how to pass the modified (or not) data from dataGridView back to dataBase`s table. | |
Re: [QUOTE=Tank50;1472061].I want to appear the new window at the right side lower corner in combo box.[/QUOTE] You have a mainForm. And then you have a comboBox on it. And when you select an item from it, a new form has to appear in the button-right corner, with some info in … | |
Re: Yes it is, but you can pass it between classes as parametes, or directly if you mark is as public. Example: [CODE] public class Class1 { private string variable1; public Class1() { //constructor of class1 } private void MethodInClass1() { variable = "a1"; Class2 c2 = new Class2(); c2.var2 = … | |
Re: Code looks fine to me, including the constructror. The only thing that bothers me, are the names of the nameSpace and the class name - they are both the same. Maybe is this the issue. Not sure, never tried with both same names. Mitja | |
Re: As said, you have to create your own form, which will look like a messageBox. There you can do what ever you want. | |
Re: You would like to get all the values from a dgv`s row? Lets say you want to get data from 5th row (dgv has 3 columns): [CODE] string = column1 = dgv[0,6].Value.ToString(); string = column2 = dgv[1,6].Value.ToString(); string = column3 = dgv[2,6].Value.ToString(); [/CODE] If the column has a default type … | |
Re: This might help you: [CODE] public partial class Form1 : Form { List<MyObject> list; public Form1() { InitializeComponent(); CreatingList(); GetIndex(); } private void CreatingList() { list = new List<MyObject>(); MyObject m1 = new MyObject(1, "one"); MyObject m2 = new MyObject(2, "two"); list.Add(m1); list.Add(m2); } private void GetIndex() { int index1 … | |
Re: When creating a new button, create a Click event with it: [CODE] public void CreateButtons(int NumX, int NumY) { this.Location = new Point(2, 2); this.Size = new Size((NumX + 1) * 40 - 20, (NumY + 1) * 40); int temp; for (int i = 0; i < NumX; i++) … | |
Re: Simply, ad zach said, from the dropDown menu select Build, and them Publish YourProject. Then you go Next, select from CD/DVD, select app. will not check for updates (in most cases)and Finish. Thats it. You have a setup.exe, and everyone can install it (this is the simplyest working way). | |
The code gets all the files (only names, if you want to get the paths too, simply remove for loop (its only one) from the code. Files are stored into a generic list. Mitja | |
Re: Would you mind pasting the code in here? Use code block! | |
Re: Are you sre those two textBoxes really contains integers ONLY? Usually you get this kind of error, if the string, which you want to convert to integer, does NOT contains only numbers (with not letters, no dots, or commas). Do a check if there really isa int: [CODE] private void … | |
Re: Since you didnt say much about your issue (I would need some better explanation oif the problem), I will show you how to disable/enable cells. [CODE] dgv[columnIndex, rowIndex].ReadOnly = true; //this will disable specific cell! //set to false, if you want it to be enable again! //beside, if you want … | |
Re: Of course it will fire. The event is about to fire when ever the value in each cell changes. So that means that it will fire every time something comes into each cell. You can avoid this by using a flag - a boolean variable, which you will set to … | |
Re: Your code looks very confused. From beginning (from the top down): Your 1st method "Insert_ItemRecords() method is a returned type of boolean, but you return SqlCommand object - this is not good at all. At the bottom where you call this method, you simply call it , without the return … | |
Re: [QUOTE=virusisfound;1462866] in my line the [B]conifigurationManager[/B] is not available in the config list.[/QUOTE] You need to add a new Reference (System.Configuration) - right click on References in Solution explorer and choose Add refernece. Go down and select System.Configuration. Now you write: [CODE]private static string connString = ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString;[/CODE] and when you … | |
Re: 1. You NEED parameters, if you want to do exactly what you have to do... but it would be bette to use them in the parametrized query, that means that you add parameters with sql(oleDB) command object, And not insert parameters directly into the query. - So answer in NO … | |
Re: You have to create a object Form as global variable - so it can be accessed from every place in the class, and there where you want to open it, simple create a new instance of the Form object and open it: [CODE] public partial class Form1 : Form { … | |
Re: Whole code would look like (as Momerath explained): [CODE] dataAdapter.InsertCommand = connection.CreateCommand(); dataAdapter.InsertCommand.CommandText = "insert into Computer (Id, Name) values (@id, @name)"; dataAdapter.InsertCommand.Parameters.Add("@d", SqlDbType.NVarChar, 16, "Id"); dataAdapter.InsertCommand.Parameters.Add("@name", SqlDbType.NVarChar, 16, "Name"); [/CODE] | |
Re: I did two examples for you, one is to use string array the other is to use char (which I prefer most in this case): [CODE] private void ReadingFile() { List<string> list = new List<string>(); string path = @"C:\1\test11.txt"; string[] lines = System.IO.File.ReadAllLines(path); //1. option: for (int i = 0; … | |
Re: [QUOTE=manugm_1987;1462440]Is there a way to limit the number of records to be inserted into a table using ado.net?[/QUOTE] What kind of table are you talking about? DataTable? | |
Re: I agree with NewOrder, your code (console`s version) is very poor, and only with that, nothing will work. For doing this kind of code, you need at least two applications, server and client. Please take a look at here how it should be done (in a very basic edition): [url]http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=69[/url] | |
Re: Why you dont clear it before drawing it? Just look of a method Clear(); btw, which chart do you use? | |
Re: You said you want to save all items from a listView, not SelectedItem. So why are you using Selecteditem property? What you hav to do it to loop through all the rows and get the values from all the columns (while in a particualar row), like this: [CODE] //... string … | |
Re: ADDED: Or get the width and height of the monitor and set the application to those values (if you want to maximize it). Mitja | |
Re: kishor20, I will go back to your 1st post... I would suggest you not to re-build or trying using some of pre-made project, becuase this is very time consuming, and you will never have all what you had needed on the beginning, so... it`s bette to star from the beginning, … | |
Re: This is might help you out: [CODE] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; //dont forget to add this namespace!!! namespace Feb02Exercise { public partial class Form1 : Form { Timer timer1; Stopwatch stopWatch1; bool bTimerStopped; public Form1() { … | |
Re: You mean table as DataTable? DataTable cannot be bind to dgv control. You can only populate dgv with using DataRow object, like for instance: [CODE] dataGridView1.Columns.Add("col1", "ID"); dataGridView1.Columns.Add("col2", "NAME"); string[] array1 = new string[] { "one", "two", "three" }; table = new DataTable("myTable"); table.Columns.Add(new DataColumn("id", typeof(int))); table.Columns.Add(new DataColumn("name", typeof(string))); DataRow … | |
Re: You need a correct connection string to the server. I will guess: this is a default connection string type: "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;" you can see you need 4 different data, fill them in and you can access to user db on hostMaster. As simple as that. | |
Re: You didnt say anything about the listView (as is in your code). And your explanation of the issue is very poor - hard to understand what exactly would you like to do. So lets go imagine... EDIT (after some hours, when all was thought out well :) ): you have … | |
Re: or create it a bitr shorter: [CODE] int rowIndex = 0; int columnIndex = 0; for (int i = 0; i < 4; i++) { TextBox Text = new TextBox(); Text.Name = "text+" + i + 1; Text.TextChanged += new System.EventHandler(this.TB_TextChanged); if (i % 2 == 0 && i > … | |
Re: ddanbe, but this will only get folders, not files. I think he want to get all files in wanted directory, and in all subdirectories, if Im not mistaken. This for example will return all the file paths: string[] filePaths = Directory.GetFiles(@"C:\1", "*.*", SearchOption.AllDirectories); | |
Re: Save them into DataTable and pass it back to db: [url]http://msdn.microsoft.com/en-us/library/59x02y99.aspx[/url] | |
Re: Please provide us some more information, about what exactly are you trying to validate. | |
![]() | Re: The problem is that you do changes in dgv. So if you want to write all the data from dgv to xml, its best to use DataTable object. Create in on form load, and when you want to save the data into xml, pass data from dgv to dataTable, and … ![]() |
Re: Login form has to appear before MainForm.Take a look into this code, how to pass data: [CODE] //program.cs (where is the Main() method): using (Login login = new Login()) { login.StartPosition = FormStartPosition.CenterScreen; if (login.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(login.strUserName)); } } //LOGIN FORM: public partial class Login : Form … | |
Re: This is the only text you have in the file: location { x=0.35 y=0.56 z=-0.5 } ?? or there is more, and you want to 1st find the text "Location" and th values inside brackets? | |
Re: Would you please explain a bit better what would you like to pass where. You only said you have 2 forms, on both there are dataGridViews. And when you add a tick onto dgvCheckBoxColumn this exact row`s data has to pass to another form. Can you please explain Exactly what … | |
Re: I repaired it, but there is a problem with the code: [CODE]if (digit4 != '-') {}[/CODE] I dont know what you have meant, but if user enters q or Q (to quit the program), the code goes into that if, and changes errorFlag to -4. Thats why user is unable … | |
Re: As Momerath said, and I would add only that you do not create a new insatance of a Timer class ones again when pressing a start button! Try to change the code into: [CODE] public partial class Form1 : Form { Timer t1; // timer 1 Timer t2; // timer … | |
Re: This is my code (I actually use it as well): [CODE] public static bool LogingInMethod(string userName, string password) { bool result = false; string sqlQuery = "SELECT UserName, Password FROM Users WHERE UserName ='" + userName + "'"; using (SqlConnection sqlConn = new SqlConnection(p)) { SqlCommand cmd = new SqlCommand(sqlQuery, … | |
Re: I did a semple code, to see what dataSet and dataTables are all about. To test this method, paste it into a windows application project, and run it. Put a break point and go through the code line by line (with F11). [CODE] private void Method() { DataSet ds = … | |
Re: Do you want to insert a new row on the top of the dgw, or at the bottom (into a new row)? If is the last thing, you 1st need to count all the rows and then insert the values into the allRows + 1(so into a new row): [CODE]private … | |
Re: Take a look into this example, which invokes the label: [CODE] public partial class Form1 : Form { delegate void MyDelegate(string msg); public Form1() { InitializeComponent(); labelShow.Text = ""; } private void buttonStart_Click(object sender, EventArgs e) { Thread thread = new Thread(new ThreadStart(DoingTimeConsumingStuff)); thread.Start(); } private void DoingTimeConsumingStuff() { for … | |
Re: btw, one thing to mention here: Why you dont create a login form before the main one even appears? You can use DialogResult() method to check if the user has entered the correct login data or not. How to use it, you can take a look on example here: [url]http://support.microsoft.com/kb/816145[/url] … | |
Re: If I understand you, you would like to delete rows. If all the requirements (WHICH ONE??) aren`t meat, the user is unable to delete selected row and the error message pops up. But what I do not understand is what is wrong with the code - so would you be … | |
Re: Only ones of course. Different would be something like that: [CODE] string[] array = GetString(); //method GetString returns an array of strings //you you go through a foreach loop like it: foreach(string str in array) { here you can loop through str string! } [/CODE] |
The End.