1,469 Posted Topics
Re: Do you populate dgv with all the "layout id" from the database? I means are the all rows from dataBase, present in the dgv? And how do you populate dgv? Is it data bound, or not? If it is, you can loop through the dataTable of particular column, and check … | |
Re: I did repair the code, and it should work now: [CODE] private void updatetaskstatus() { using(SqlConnection con = new SqlConnection()) { con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Effort Tracker System\\Effort Tracker System\\ETS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlCommand cmd1 = new SqlCommand("SELECT Task FROM tblTask", con); con.Open(); using(SqlDataReader alltasks = cmd1.ExecuteReader()) { while (alltasks.Read()) { … | |
| |
Re: Try this code, it works 100%: [CODE] private void WriteToFile() { string line = "-0.025 0.15 0.15 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5 -0.05 0.1333333 0.2 0.4 0.5"; string path = @"C:\1\test27.txt"; using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) … | |
Re: Are you talking about generic method? If the operations performed by several overloaded methods are identical for each argument type, the overloaded methods can be more compactly and conveniently coded using a generic method. You can write a single generic method declaration that can be called at different times with … | |
Re: GridView is a grid consisted by the rows and columns. Each row and column gather a cell. You can change, add or delete every cell, row and column. ReportView - I would assume that this is ReportViewer. Its meant to show data to print (like CrystalReportViewer). | |
Re: Lets clear some things now, and lets look into your example code: [CODE] DateTime dateOfEvent = Convert.ToDateTime(dtpReservationDate.Value.ToLongDateString());[/CODE] You dont need to assign a method "ToLongDateString()", because you want to get a real DateTime value. And real dateTime value has nothing to do with the string date (or string time). It … | |
Re: Hello :) in your 2nd example, the code will not get through. Code will compile, but will be an error on line 3). You will get an error "Object reference not set to an instance of an object.". Thats because a1 was not instantiated yet, and thats why you cannot … | |
Re: I would say there is no difference, just that the your 1st example shows to which property some value is relied to. But if you know what you are doing, and know code well, its surely better to use 2nd option, which is the same as 1st one, but faster … | |
Re: I dont know what your list represents. So it would be good to add some code or explanation to the thread. Check out my code I did yesterday here: [url]http://www.daniweb.com/software-development/csharp/threads/360495[/url] As you can see Iam creating a dictionary, and use generic list<T> as Value. This how you can get values … | |
Re: if you want to check if the value is not null: [CODE] while (r.Read()) { if(r.GetValue(1) != DbNull.Value) string name = (string)r[1]; //and so on for the rest of the fields... } [/CODE] | |
Re: If you want to set all to true then you can do: [CODE] foreach (DataGridViewRow row in dataGridView1.Rows) { DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell; if (Convert.ToBoolean(chk.Value) == false) chk.Value = true; } [/CODE] If you want to set for a specific row: [CODE] foreach (DataGridViewRow row in dataGridView1.Rows) { … | |
Re: You can create as many constructors as you like. One can have no parameters, 2nd can have one, 3rd constructor can have 3 parameters and so on. When you create a new instance of a class you then pass as many parameters as you have in those constructors. It will … | |
Re: What is wrong with this code? You only posted two methods, which can tell me nothing. You have to be more precise about what do you want to achive. Can you please do a bit better explanation, or add some more code? It would really help out. | |
Re: Here you have an example code of multipidimensional array, and how to get values out of it: [CODE] int[,] array = new int[3, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; int[] newNumbers = null; for (int … | |
Re: Instead of reading whole text, and then split the lines, you can get all lines into an array directly: [CODE] string[] lines = File.ReadAllLines(@"C:\file.txt"); [/CODE] | |
Re: [QUOTE=nawaray82;1532537]...for the employee by Asking the user to enter the number of employees.[/QUOTE] What does it mean to enter the number of employees? | |
Re: 1. Create a select statement to get all the Menus to 1st dgv. 2. Create a select statement with a where clause depending of the dgv1 selection. In both use DataTables, which can be bound to the dgv controls. As simple as that. | |
Re: [CODE] List<string> list1 = new List<string>(); List<string> list2 = new List<string>(); string a = "100000"; string b = "011111"; string[] array = new string[]{a,b}; for (int i = 0; i < array.Length; i++) { if (array[i][0].ToString() == "1") list1.Add(array[i]); else list2.Add(array[i]); } [/CODE] | |
Re: My part: [CODE] string value ="some value"; if (char.IsDigit(value[0]) && char.IsLetter(value[value.Length - 1])) value = "00" + value; [/CODE] | |
Re: Hi, to add to ddanbe`s post. You can do it this way too: [CODE] foreach (DataGridViewRow row in dataGridView1.Rows) { foreach (DataGridViewCell cell in row.Cells) { //CELL here does not have a property of HeaderText. //so you can do it like ddanbe showed or: string header = dataGridView1.Columns[cell.ColumnIndex].HeaderText; } } … | |
Re: Great example showed pritesh. I would only like to show you one more simplier, but the methods are less proptective, because they are marked ass public, so you can access to them from every class, but anyway: [CODE] //form1: private void buttonAdd_Click(object sender, EventArgs e) { Form2 f2 = new … | |
Re: NO. You cannot subtract or sum dateValues. You have to use TimeSpan`s method called Subtract. like: [CODE] DateTime dt = (dateTimePicker1.Value); TimeSpan ts = DateTime.Now.Subtract(dt); textBox1.Text = (ts.Days * 30).ToString(); //or 20, or 10 [/CODE] | |
Re: [CODE] if (listView1.SelectedItems[0].SubItems[0].Text.ToString()) //... [/CODE] Items or SelectedItems means 1st column, SubItems are 2nd and more columns, depends which index do you specify in the brackets. SubItems[0] is 1st column, same as Items[0], so you have 2 options: 1. for choosing 1st column value : .SelecteItems[0].Text; 2. or choosing 2nd … | |
Re: You can use String.Format method, but it will return a string value of the time (not an actual time). [CODE] DateTime date = DateTime.Now; string strTime = String.Format("{dd.MM.yyyy hh:mm}", date);[/CODE] Do you explicitly wanna have a DateTime, and now a string? If you only wanna add time (hours) you can … | |
Re: Yep, this will not do, it the comboBox is bound to a dataSet. Try this one: [CODE] private void comboBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { int newID = Convert.ToInt32(table.Rows[table.Rows.Count - 1]["Id"]); newID++;//add new id - add 1 to last id //insert a new row to dataTable: … | |
Re: Why do you use [CODE] comboBox1.SelectedValue; [/CODE] ? Is there any particular reason? YOu would like to get thw ValueMember out of it, am I right? | |
Re: Momerath is da Man, so there will surely wont be any exceptions, if only your other ocde runs fine :) | |
Re: It this case it would be better to create some collection of the items. Lets say we use a generic list<T>, which will hold all the checked items, and those will be shown in listView2. So all you havw to do, is to copy all checked item to this list, … | |
Re: If I understand you well, you would like to update a label on from1 from some other form, am I right? For this you do not need delegates at all, and you do not need to start a new Thread either. You can do it: [CODE] //form1: public void UpdateLabel(string … | |
Re: [CODE] public Form1() { InitializeComponent(); listView1.Columns.Add("Checking", 50, HorizontalAlignment.Center); listView1.Columns.Add("Item name", -2, HorizontalAlignment.Center); listView1.View = View.Details; listView1.CheckBoxes = true; listView2.Columns.Add("Item name", 100, HorizontalAlignment.Center); listView2.View = View.Details; //add some items to listView1: for (int i = 0; i < 5; i++) { ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add("Item " + i + … | |
Re: Try this code: [CODE] SqlDataAdapter da1 = new SqlDataAdapter("select empid,citycode,name,salary from person", con); SqlDataAdapter da2 = new SqlDataAdapter("select name,citycode from city", con); DataSet ds = new DataSet("Person_City_Detaset"); DataTable dt1 = new DataTable("Person_Table"); DataTable dt2 = new DataTable("City_Table"); da1.Fill(dt1); da2.Fill(dt2); ds.Tables.AddRange(new DataTable[] { dt1, dt2 }); ds.Relations.Add("Person_City_Relation", dt2.Columns[1], dt1.Columns[1]); //use thisis … | |
Re: Instead of using that if statement: [CODE]if (Regex.IsMatch(allRead, regMatch))[/CODE] I would suggest you, before doing a loop create an array of all characters (all the words in that string) : [CODE] string allRead = testTxt.ReadToEnd(); string allChars = allRead.Split(' '); //create a new string wtih htmls: string newString = null; … | |
Re: Check here: [url]http://www.codeproject.com/KB/cs/csharpmovewindow.aspx[/url] Two ways. First: [CODE] //API functions to move the form public const int WM_NCLBUTTONDOWN = 0xA1; public const int HTCAPTION = 0x2; [DllImportAttribute("user32.dll")] public static extern bool ReleaseCapture(); [DllImportAttribute("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); //And in your mouse down event … | |
Re: I will show you how to do in both ways, becuase you didnt exactly specify in which direction you want to get a radio button check state. So from from1 to check the radioButton on form2, and from form2 to check th radioButton on form1: [CODE] //FORM1 public partial class … | |
Re: What? Lol Strange post of this CsharpChico guy. Code is even worse then of the thread`˙s creator. | |
Re: Check here: [url]http://www.codeproject.com/KB/cs/balamurali_balaji.aspx[/url] | |
Re: Tell me, which values you want to get from this upper example? In each part are these 2 numbers: 1. the number on the right side of th ">" mark, and 2. the number which is just above the next ">" mark? So in this example: >25 233966 300156 89980 … | |
Re: You can use a Dictionary collection object: [CODE] public partial class Form1 : Form { Dictionary<string, string> connStrings; public Form1() { InitializeComponent(); connStrings = new Dictionary<string, string>(); connStrings.Add("Connection string 1", "Your full connection string 1"); connStrings.Add("Connection string 2", "Your full connection string 2"); connStrings.Add("Connection string 3", "Your full connection string … | |
Re: If you still havent found the best way of showing specific data in the dgv, would you let me know? And if there is any code you have, would be more then welcome. | |
Re: You didnt start the correct way. Check out this code, I only did a half of the code, which calculates the square area: [CODE] namespace Apr11Test2 { class Program { static void Main(string[] args) { Rectangle r = new Rectangle(); Square s = new Square(4, 5); Console.WriteLine("Computed are is {0}.", … | |
Re: Try it this way: [CODE] string path = @"C:myFolder\myFile.txt"; List<int> list = new List<int>(); using (StreamReader sr = new StreamReader(path)) { string line; while ((line = sr.ReadLine()) != null) list.Add(Convert.ToInt32(line)); } //generic list<T> now has all the numbers in the collection! //generic list is better then a simple array (int[]). … | |
Re: Do this: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MyClass mc = new MyClass(); mc.MyMethod(); } } public class MyClass { public void MyMethod() { System.Windows.Forms.MessageBox.Show("This is a message from my class."); } } [/CODE] | |
Re: This was the code I did for him, and I used a Linq there (dont know why, just spontaniously I guess, even if your way is good the same way - just to assign new value to the appropriate key). Is it working now? It surely was working before too. … | |
Re: [QUOTE=salmap;1527359]Hi, Simple question.How do you rename a label? I'm trying LAbel1.Name="sk"; Please someone tell me the correct code?[/QUOTE] Why would you rename it? To use a Name property. That is not only that you would like to set a new Text property for the label? like: [CODE] label1.Text = My … | |
Re: You type float (if you have decimals), or decimal: [CODE] float a = 0.564F; float b = 0.356F; float c = a - b; [/CODE] | |
Re: I showed you in the code I gave you in some other thread. I was using dictionary collection to get the values of the columns (and a sum of them). | |
Re: So you have data in 2 DataTables? One is called Item, 2nd one is called ItemType. Can you explain ones more a bit more clearly which data would you like to show in dgv? | |
Re: You will have to create a new object. Check it out here: [url]http://www.codeproject.com/KB/buttons/RoundButton_csharp.aspx[/url] |
The End.