1,469 Posted Topics

Member Avatar for Jessurider
Member Avatar for AngelicOne

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]

Member Avatar for AngelicOne
0
126
Member Avatar for NewOrder

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.

Member Avatar for NewOrder
0
173
Member Avatar for Mitja Bonca

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.

Member Avatar for tomason
0
750
Member Avatar for Tank50

[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 …

Member Avatar for Mitja Bonca
0
116
Member Avatar for ajinkya112

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 = …

Member Avatar for Mitja Bonca
0
189
Member Avatar for carlitosway17

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

Member Avatar for carlitosway17
0
2K
Member Avatar for abhi10kumar

As said, you have to create your own form, which will look like a messageBox. There you can do what ever you want.

Member Avatar for ddanbe
0
118
Member Avatar for abhi10kumar

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 …

Member Avatar for Mitja Bonca
0
124
Member Avatar for Diamonddrake

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 …

Member Avatar for Diamonddrake
0
162
Member Avatar for staticclass

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++) …

Member Avatar for Mitja Bonca
0
172
Member Avatar for judithSampathwa

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).

Member Avatar for Mitja Bonca
0
208
Member Avatar for Mitja Bonca

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

Member Avatar for ShahanDev
0
1K
Member Avatar for Jessurider
Member Avatar for summey

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 …

Member Avatar for summey
0
137
Member Avatar for MARKAND911

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 …

Member Avatar for Mitja Bonca
0
2K
Member Avatar for erdinc27

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 …

Member Avatar for Mitja Bonca
0
142
Member Avatar for peggie1990

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 …

Member Avatar for Mitja Bonca
0
139
Member Avatar for virusisfound

[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 …

Member Avatar for virusisfound
0
243
Member Avatar for pacheco

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 …

Member Avatar for Mitja Bonca
0
107
Member Avatar for valter

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 { …

Member Avatar for valter
0
1K
Member Avatar for Acidburn

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]

Member Avatar for Mitja Bonca
0
188
Member Avatar for junioryz

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; …

Member Avatar for Mitja Bonca
0
2K
Member Avatar for manugm_1987

[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?

Member Avatar for manugm_1987
0
117
Member Avatar for NewOrder

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]

Member Avatar for NewOrder
0
163
Member Avatar for coastcode

Why you dont clear it before drawing it? Just look of a method Clear(); btw, which chart do you use?

Member Avatar for kashor
0
113
Member Avatar for GAME

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 …

Member Avatar for Mitja Bonca
0
969
Member Avatar for Mr.BunyRabit

ADDED: Or get the width and height of the monitor and set the application to those values (if you want to maximize it). Mitja

Member Avatar for Mitja Bonca
0
131
Member Avatar for kishor20

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, …

Member Avatar for kishor20
0
443
Member Avatar for Tellalca

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() { …

Member Avatar for rohand
0
629
Member Avatar for virusisfound

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 …

Member Avatar for virusisfound
0
266
Member Avatar for GAME

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.

Member Avatar for Ketsuekiame
0
155
Member Avatar for JannuBl22t

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 …

Member Avatar for Mitja Bonca
0
115
Member Avatar for anandguptastar

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 > …

Member Avatar for anandguptastar
0
5K
Member Avatar for niths

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);

Member Avatar for Mitja Bonca
0
520
Member Avatar for mahdi68

Save them into DataTable and pass it back to db: [url]http://msdn.microsoft.com/en-us/library/59x02y99.aspx[/url]

Member Avatar for Mitja Bonca
0
110
Member Avatar for shallug

Please provide us some more information, about what exactly are you trying to validate.

Member Avatar for umamahesh2020
0
227
Member Avatar for kardo

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 …

Member Avatar for kardo
0
2K
Member Avatar for AngelicOne

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 …

Member Avatar for Mitja Bonca
0
109
Member Avatar for GizmoPower

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?

Member Avatar for GizmoPower
0
1K
Member Avatar for bhagawatshinde

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 …

Member Avatar for Mitja Bonca
0
349
Member Avatar for revjim44

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 …

Member Avatar for Mitja Bonca
0
409
Member Avatar for zupa

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 …

Member Avatar for Mitja Bonca
0
291
Member Avatar for GAME

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, …

Member Avatar for GAME
0
157
Member Avatar for Mr.BunyRabit

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 = …

Member Avatar for Mitja Bonca
0
261
Member Avatar for Mr.BunyRabit

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 …

Member Avatar for Mr.BunyRabit
0
107
Member Avatar for JannuBl22t

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 …

Member Avatar for lolafuertes
0
128
Member Avatar for McvR

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] …

Member Avatar for McvR
0
173
Member Avatar for judithSampathwa

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 …

Member Avatar for judithSampathwa
0
255
Member Avatar for moni94

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]

Member Avatar for Mitja Bonca
0
115

The End.