1,469 Posted Topics
Re: [QUOTE=lxXTaCoXxl;1515092]If you're just checking to see if the vertical scroll bar is enabled then you can tell the textbox to write multiple lines of text. Like: [CODE]void appLaunch() { richTextBox1.Text = "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine … | |
Re: Check out this code for comparing two arrays: [CODE] int[] array1 = { 1, 2, 3, 4, 5, 6 }; int[] array2 = { 1, 3, 4, 4, 5, 7 }; int[] newArray = null; int k = 1; for (int i = 0; i < array1.Length; i++) { if … | |
Re: I strongly recommend you to switch to dataGridView - this is especially important when it comes to editing columns. ListView is so clumsy on this area. really. DGV is a far way better control. ListView is only meant to show data, not to edit it, even if its possible. And … | |
Re: Why would you delete whole dgv. You dont need to. If you want to delete the row, and the dgv is bound to a data source, you have to remove the row from this data source. Then will surely work. Mitja | |
Re: What exactly are you trying to do? Do you want to chage the state of the tick? From true to false in runtime? Because your code has no sence to checking if the tick is in both states. Just tell me what exactly would you like to do. Mitja | |
Re: As ddanbe said. I will only show an example: [CODE] DateTime dateNow = DateTime.Now; // I will add just an example dateTime: DateTime dateFromDataBase = new DateTime(2011, 3, 21); //comparing both dates: if (dateNow.Date == dateFromDataBase.Date) { //if both dates are equal do code in here: } else { //if … | |
| |
Re: This is surely again one of the school projects. You have to create a win form from console. Ok, I did your homework, and here`s the code: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int intDrawersPerDesk = … | |
Re: In which format do you save it? I hope not it txt. Iam affraid best solutin your be to use *.doc. But in this case you would need some additional code for Converting the cryped doc code. | |
Re: try this: [CODE] int rowSelected = dataGridView1.CurrentCell.RowIndex; [/CODE] | |
Re: Lets say you were doing C# for 3 years. But now we have to ask you, what were you doing in these past 3 years? Have you learned every single day (for at least 2-3 hours for day), or did you only occasionally used any book(s) and Visual Studio for … | |
Re: In which format do you have "0030"? | |
Re: Man, how do I know what is "SplitItem" variable? Is this a string (which cannot be), is an array or any other collection type? PLEASE, try to paste all the code needed for us, if you want any decent help. Lets says its an array (string[]). The same goes for … | |
Re: What hash funstion do you mean? There is no operation with this name in Lambda Expressions. But here is an example with Intersept operator: [CODE] SortedList<int, int> s1 = new SortedList<int, int>(); for (int i = 0; i < 10; i++) s1.Add(i, i); //ADDED: 0,1,2,3,4,5,6,7,8,9 SortedList<int, int> s2 = new … | |
Re: What exactly are you trying to do? Before pasting some code here, would be nice to do some basic explanation of what is your project aobut. So we can have a clue about, and then its a way easier for us to help you out. Now I dont know what … | |
Re: You want to sort how? What has to do spaces , tabs, - * here? | |
Re: You cad do it like: [CODE] string answare = "j"; bool again = (answare == "j" || answare == "J") ? true : false; [/CODE] about your issue: as ddanbe explained, (') is a type char, and I presume that variable answare is a type string ("). So these two … | |
Re: Hi, what kind of reports? Crystal Reports, or some else? You can find some help about Crystal Reports here (which are by best by far - in my opinion): [url]http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx[/url] [url]http://www.codeproject.com/KB/database/MySQLCrystal.aspx[/url] [url]http://www.codeproject.com/KB/cs/Dynamic_Crystal_Report.aspx[/url] Hope it helps, Mitja | |
Re: What do you mean with radion buttons direstions? YOu have only one "main textBox" so how will you be using these 2 radionbuttons? What would be the difference in selecting one or the other? Mitja | |
Re: Would you mind showing the code? The problem is becuase you have already opened the dataReader. For sure you have a loop and you are trying to open already opened dataReader. Double check the code, if you do not find an error, please paste the code in here. Mitja | |
Re: [CODE] string writetext = ListItemCom2.SelectedItems.ToString(); [/CODE] Is the error. You want to get an array and put it into a stirng. No go. You needa loop, which will go through the listBox items, like: [CODE] FileStream fs2 = new FileStream(@"C:\Users\Fish\Desktop\fyp-coding\Combine.txt", FileMode.Append, FileAccess.Write, FileShare.Write);//create text file StreamWriter sw2 = new StreamWriter(fs2, … | |
Re: Do you talk about DataTables, or do you mean table in database? In any case you surely can insert only two values (into two columns out of four columns). | |
Re: Instead of using so many ArrayList, you can use Dictionary: [CODE] public partial class Form1 : Form { Dictionary<string, ArrayList> dic; public Form1() { InitializeComponent(); comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); CreateMain(); } private void CreateMain() { dic = new Dictionary<string, ArrayList>(); string[] array = { "bankDetails", "accDetails", "transDetails" }; foreach (string … | |
Re: Check it out here: [url]http://www.xmlfox.com/print_datagridview.htm[/url] and here: [url]http://www.codeproject.com/KB/grid/PrintDataGridView.aspx[/url] Mitja | |
Re: Try this code: [CODE] private void button1_Click(object sender, EventArgs e) { string path = @"C:\1\test21.txt"; if (!File.Exists(path)) { FileStream fs = File.Create(path); fs.Close(); } using (TextWriter tw = File.AppendText(path)) { foreach (string item in listBox1.Items) tw.WriteLine(item); } } [/CODE] This code addes (appends) the text from listBox to the file … | |
Re: Are you inserting into database, ot selecting from it? Regarding on your code (when using ExecuteNonQuery() method) you are inserting. You have to change your format that will suit to the database` dateTime column format. You can do it like: [CODE] DateTime date = dateTimePicker1.Value.Date; string sDate = date.ToString("dd-MM-yy", System.Globalization.CultureInfo.InvariantCulture); … | |
Re: Ok, sortedList, what is the Key are Value type? Even the Linq query can deffer a lot, depending on the types. Is it somethink like: SortedList<string, string> or do you use any custom objects inside? Mitja | |
Re: Try using FileOpenDialog method to choose the image, and then PictureBox control to show the image inside of it: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog open = new OpenFileDialog(); open.InitialDirectory = @"C:\"; open.Filter … | |
Re: DataSource is a property of some controls (like DataGridView) which is used for binding data to these Controls. The best would be to look an example: [CODE] public partial class Form1 : Form { DataGridView dgv; DataTable table; BindingSource bs; public Form1() { InitializeComponent(); dgv = new DataGridView(); dgv.Location = … | |
Re: Check out this code: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); dataGridView1.AllowUserToAddRows = false; dataGridView1.Columns.Add("col1", "Column 1"); dataGridView1.Columns.Add("col2", "Column 2"); DataGridViewCheckBoxColumn column3 = AddingCheckBoxColumn(); dataGridView1.Columns.Add(column3); for (int i = 1; i < 10; i++) dataGridView1.Rows.Add(i, "Item " + i, false); } private DataGridViewCheckBoxColumn AddingCheckBoxColumn() { … | |
Re: Check this out: [CODE] SortedList<int, int> sList = new SortedList<int, int>(); int[] arrayKey = { 12, 13, 14, 23, 24, 34, 12, 13, 14, 23, 24, 34 }; int[] arrayValue = { 1, 1, 1, 1, 1, 1, 2, 3, 3, 2, 2, 3 }; for (int i = 0; … | |
Re: [CODE] TextBox[] tbs = new TextBox[] { textBox1, textBox2 }; decimal total = 0M; for(int i = 0; i < tbs.Lenght; i++) total += ConvertToDecimal(tbs[i].Text); [/CODE] | |
Re: Maybe you can use Form_Load event hanlder, or overriden OnShow. | |
Re: In win forms, you will have to specify the new position. The human eye recognize 25 pictures for second, so you will have to move the picture 25 times per second (per few inches every move). In TimerTick event you have to execte the move. You can do your own … | |
Re: Just one think: What will happen with characters P in your case? There are two P letters in your word, so which index will be chosen for it? This is not a good way to contiune. Just to make you think a bit better. Mitja | |
Re: Or this one: [CODE] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string proc = Process.GetCurrentProcess().ProcessName; Process[] processes = Process.GetProcessesByName(proc); if (processes.Length > 1) { MessageBox.Show("Application already running...", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { } } [/CODE] | |
Re: Do you talk about sql query or...? If so, this is it: [CODE] string query = @"SELECT * FROM MyTable WHERE StartTime >= @start AND EndTime <= @end"; //pass the parameters to @start and @end time [/CODE] | |
Re: Just to add to ddanbe`s post: But you need to have both instances avaliable and forms in state "Open", otherwise will be an error. You can set both Forms asd global and check if they are null whihle trying to close them: [CODE] //in form1: Form2 f2; Form3 f3: Form1() … | |
Re: Try this one: [CODE] string path = @"C:\1\testFile.txt"; using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) { using (TextWriter tw = new StreamWriter(fs)) { //use tw variable to do writing! } } [/CODE] | |
Re: pArray is an array of custom object, in your case the Person is a class. Array of cusom class means you have (will have) more then one Person. If there is more then one, you need to put them into an array for having them together. Mitja | |
Re: When you open form2, pass a parameter of dateTimePicker (a value of it) in constructor to form2. So now you have both values on forms. You only get a value of dateTimePicker from form2 and compare them. | |
Re: You can see from the exception, that your conversation is not ok. Try to do: [CODE] DateTime dateDate = Convert.ToDateTime(reader["dtFrom"]); //column "dtFrom" has to be type of DateTime! [/CODE] but as it seems from your excetion, your column "dtFrom" is a type of varchar (so string, and no DateTime). So … | |
Re: Take a look at this code I made some days ago. It gets the images from DB into ImageList: [CODE] List<ImageList> list; public Form1() { InitializeComponent(); } private void buttonLoad_Click(object sender, EventArgs e) { list = new List<ImageList>(); using (SqlConnection sqlConn = new SqlConnection("connString")) { string query = String.Format(@"SELECT PictureName, … | |
Re: damn, what a mess. Why dont you use stored procedure? You will get rid of these looong code. And some work on optimizing the sql query will surely do the trick. I cannot even see what is all about this strange query, so hard to tell what cound be wrong … | |
Re: You mean not to get values into dataTable? Something like using DaraReader? [CODE] private void GetDataDirectly(int id) { using (SqlConnection sqlConn = new SqlConnection("connectionString")) { string query = @"SELECT a, b ,c FROM MyTable WHERE IdTable = @id"; SqlCommand cmd = new SqlCommand(query, sqlConn); cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; using (SqlDataReader … | |
Re: You only instantiated TextBox, but its not created yet. | |
Re: Why you dont use a Dictionary? With: [CODE] Dictionary<int, List<int>> dic; //1st part is a key, 2nd part (generic list) are values [/CODE] | |
Re: Hi, would you mind pasting some of the code in here? So we can see what is going wrong? thx Mitja | |
Re: Check this code I did a couple of weeks ago. The pictues are retreived from DB and shown in listbox: [CODE] List<ImageList> list; public Form1() { InitializeComponent(); } private void buttonLoad_Click(object sender, EventArgs e) { this.listBox1.Items.Clear(); list = new List<ImageList>(); using (SqlConnection sqlConn = new SqlConnection(connString)) { string query = … |
The End.