1,469 Posted Topics

Member Avatar for sushanth08

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 …

Member Avatar for Mitja Bonca
0
4K
Member Avatar for kirtee2209

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

Member Avatar for Mitja Bonca
0
86
Member Avatar for g2gayan
Member Avatar for Mark_48

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

Member Avatar for abelLazm
1
699
Member Avatar for vedro-compota

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 …

Member Avatar for vedro-compota
0
138
Member Avatar for msnduty

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

Member Avatar for Mitja Bonca
0
38
Member Avatar for xanawa

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 …

Member Avatar for xanawa
0
147
Member Avatar for vedro-compota

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 …

Member Avatar for vedro-compota
0
96
Member Avatar for croker10

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 …

Member Avatar for croker10
0
140
Member Avatar for Mark_48

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 …

Member Avatar for Mark_48
0
95
Member Avatar for xanawa

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]

Member Avatar for xanawa
0
83
Member Avatar for xanawa

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

Member Avatar for Mitja Bonca
0
116
Member Avatar for vedro-compota

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 …

Member Avatar for vedro-compota
0
106
Member Avatar for johnt68

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.

Member Avatar for johnt68
0
581
Member Avatar for Mark_48

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 …

Member Avatar for Mark_48
0
96
Member Avatar for Mark_48

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]

Member Avatar for Mark_48
0
140
Member Avatar for nawaray82

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

Member Avatar for abelLazm
0
172
Member Avatar for xanawa

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.

Member Avatar for xanawa
0
101
Member Avatar for Mark_48

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

Member Avatar for Mark_48
0
127
Member Avatar for muzikhera

My part: [CODE] string value ="some value"; if (char.IsDigit(value[0]) && char.IsLetter(value[value.Length - 1])) value = "00" + value; [/CODE]

Member Avatar for Mitja Bonca
0
385
Member Avatar for JakeA

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

Member Avatar for abelLazm
0
348
Member Avatar for xanawa

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 …

Member Avatar for xanawa
0
90
Member Avatar for niketakapoor

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]

Member Avatar for Mitja Bonca
0
116
Member Avatar for Skeldave

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

Member Avatar for abelLazm
0
116
Member Avatar for Nikhil R
Member Avatar for kirtee2209

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 …

Member Avatar for Mitja Bonca
1
5K
Member Avatar for xanawa

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

Member Avatar for xanawa
0
88
Member Avatar for niketakapoor

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?

Member Avatar for Mitja Bonca
0
90
Member Avatar for niketakapoor

Momerath is da Man, so there will surely wont be any exceptions, if only your other ocde runs fine :)

Member Avatar for niketakapoor
0
164
Member Avatar for IDC_Sharp

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

Member Avatar for Mitja Bonca
0
148
Member Avatar for Suzie999

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 …

Member Avatar for Suzie999
0
206
Member Avatar for IDC_Sharp

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

Member Avatar for vincezed
0
1K
Member Avatar for ashish101

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 …

Member Avatar for ashish101
0
706
Member Avatar for TheDocterd

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

Member Avatar for TheDocterd
0
109
Member Avatar for Suzie999

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 …

Member Avatar for Suzie999
0
120
Member Avatar for zifina

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 …

Member Avatar for Mitja Bonca
0
990
Member Avatar for yousafc#

What? Lol Strange post of this CsharpChico guy. Code is even worse then of the thread`˙s creator.

Member Avatar for CsharpChico
0
100
Member Avatar for easa056
Member Avatar for weasel7711

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 …

Member Avatar for weasel7711
0
458
Member Avatar for stefilina

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 …

Member Avatar for Mitja Bonca
0
536
Member Avatar for xanawa

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.

Member Avatar for Mitja Bonca
0
124
Member Avatar for shyla

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}.", …

Member Avatar for ddanbe
0
200
Member Avatar for CrazyMisho

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[]). …

Member Avatar for Momerath
0
302
Member Avatar for eoop.org

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]

Member Avatar for divin757
0
167
Member Avatar for Mark_48

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

Member Avatar for Mitja Bonca
0
159
Member Avatar for salmap

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

Member Avatar for abelLazm
0
234
Member Avatar for Mark_48

You type float (if you have decimals), or decimal: [CODE] float a = 0.564F; float b = 0.356F; float c = a - b; [/CODE]

Member Avatar for Mitja Bonca
0
6K
Member Avatar for Mark_48

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

Member Avatar for Mark_48
0
112
Member Avatar for xanawa

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?

Member Avatar for Saikalyankumar
0
114
Member Avatar for xanawa

You will have to create a new object. Check it out here: [url]http://www.codeproject.com/KB/buttons/RoundButton_csharp.aspx[/url]

Member Avatar for abelLazm
0
86

The End.