1,469 Posted Topics
Re: Do it this way: [CODE] private void button1_Click(object sender, EventArgs e) { DateTime date = DateTime.MinValue; if (!DateTime.TryParse(textBox1.Text, out date)) { string[] strSplit = textBox1.Text.Split('/'); if (strSplit.Length == 1) date = new DateTime(int.Parse(strSplit[0]), 1, 1); else if (strSplit.Length == 2) date = new DateTime(int.Parse(strSplit[0]), int.Parse(strSplit[1]), 1); } MessageBox.Show("Real date time … | |
Re: If no parameters to pass: [CODE] //1. way: new Thread(new ThreadStart(MethodNoParams)).Start();//calling new method //2. longer way (if you need a "t" variable maybe): Thread t = new Thread(new ThreadStart(MethodNoParams)); //calling new method t.Start(); [/CODE] If parameters to pass: [CODE] object obj ="some param"; Thread t1 = new Thread(new ParameterizedThreadStart(MethodWithParams)); //calling … | |
Re: int array cannot be empty. Empty is for string. Int can have only numbers. So when you initialize a new integer array all indexes set to zero This is 0 and not empty. | |
Re: As charlybones said, there is 100% a problem in the connection string structure. Remove Integrated Security=True from your connection string and (optional) add Persist Security Info=True; From MSDN: Integrated Security - When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are … | |
Re: You can always use try-catch blocks to catch the exception. But in this cases of yours it seems not to need one. If your method has a return type, you have to return this type in any place in the Sum method. Otherwise the compiler will throw an error. You … | |
Re: But TextChaged event does. Use this one, and do restrictions inside this event. | |
Re: So this means 2 things: - or you dont retreive the right data - or you dont have the correctly. Can we see some of your code that does these two things? | |
Re: You can pass it into constructor of the class and use it: [CODE] class Main { Piece[,] board = new Piece[9, 8]; private void GoToMath() { //code... MathFunction mf = new MathFunction(board); //pass data to other class board = mf.DoSomeWork(); //do some work there, and return data } } class … | |
Re: If your DGV is data bound (so the DGV`s property DataSource is used), then all the changes made in the DGV will automatically reflect in the dataTable (or dataSet) as well. Then if you want to do updates in the database as well, you have to use Update SqlCommand. Take … | |
Re: You didnt set the return type to the setLenght method. You have to change the code to: [CODE] static void Main() { int[] myArray = new int[4]; myArray = setLength(myArray, 8); } static int[] setLength(int[] myArray, int length) { Array.Resize(ref myArray, length); return myArray; } [/CODE] or you can use … | |
Re: [QUOTE=jgat2011;1671548]Hi every one! I would like to know if it's possible to have differents items in a combo box in each row. It there is way. Please help!!! Thanks[/QUOTE] Hi, you will have to do a loop through all the rows of datagrid and based on othe column set the … | |
Re: You can subscribe to a KeyPress event of textbox control, and use this code: [CODE] private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b') e.Handled = !System.Uri.IsHexDigit(e.KeyChar); } [/CODE] Or TextChanged event: [CODE] private void textBox1_TextChanged(object sender, EventArgs e) { string item = textBox1.Text; int n = 0; … | |
Re: 1st of all: Do not change your controls (textBox in this case) access modifier. Leave it as private (never change it to public, because this is the worst thing you can do). There ar plenty of other ways to access the control, but directly from inside the class (form) where … | |
Re: or: [CODE] txtDisplay.Text = txtDisplay.Text.Remove(txtDisplay.Text.Length - 1); [/CODE] | |
Re: try: [CODE] PictureBox[] pbs; void textBox1_TextChanged(object sender, EventArgs) { int num =0; if(int.TryParse(textBox1.Text, out num)) { pbs = new PictureBox[num]; int x = 20, y = 20; for(int i = 0; i < pbs.Lenght; i++) { pbs[i] = new PictureBox(); pbs[i].Name = "pictureBox" + (i + 1); pbs[i].Location = new … | |
Re: Check this out: [CODE] Private Shared Sub Main(args As String()) Dim [date] As DateTime = DateTime.Today Dim daysNames As String() = GetDaysNames([date]) 'use each day (or show it) For Each days As String In daysNames Next End Sub Private Shared Function GetDaysNames([date] As DateTime) As String() Dim daysInMonth As Integer … | |
Re: [QUOTE=r_james14;1672088] bghtyhgfr5674456_120411_3215. The last four digits the time, middle set the date.[/QUOTE] How is 3215 the time?? What it represents? Seconds? Because 32hours and 15 minutes cannot be in one day! | |
Re: That you dont have two databases? So, inserting on one, and looking into the other? It might occur this (at least I have a couple of issues with it). | |
Re: Yes, to extend Chris`s code: [CODE] //in TextChanged event hander of textBox1: // string myID = Convert.ToInt32(textBox1.Text.Trim()); SqlConnection conn = new SqlConnection("connString"); SqlCommand cmd = new SqlCommand(); cmd.CommandText = @"SELECT Column1, Column2 FROM MyTable WHERE ColumnID = @param"; cmd.Parameters.Add("@param", SqlDbType.Int).Value = myID; SqlDataReader reader = cmd.ExecuteReader(); if(reader.Read()) { textBox2.Text = … | |
Re: If it expects four digits, then its input cannot be in the form of an int. It must be a string. The number of decimal digits has no meaning in the 'int' type - it's not natively an decimal type. (It's actually a 32-digit binary type. It's just that C# … | |
Re: You can create a seperate custom class which will hold the data. In any of the form you must have a reference (which has to be instantiated only one - on beginning) to this class; so you can access to the data on the class. The data can be in … | |
Re: 1. Do you mean one reference? If so, there is no point in this. You can simple without any harm and time consumption create a new connection reference [I](connection conn = new connection("string");[/I]. No. The command will take those data that are currently available on the server. So if command1 … | |
Re: Why you dont get the image directly out of the cell? You dont need to parse it to object. Example: [CODE] public Form1() { InitializeComponent(); //creating image column: DataGridViewImageColumn imageColumn = new DataGridViewImageColumn(); { imageColumn.Name = "colImages"; imageColumn.HeaderText = "Images"; imageColumn.Width = 100; imageColumn.ImageLayout = DataGridViewImageCellLayout.Normal; imageColumn.CellTemplate = new DataGridViewImageCell(false); … | |
Re: Hi, check [URL="http://www.akadia.com/services/dotnet_databinding.html"]this link[/URL]. Its all there. | |
Re: Will this be a windows application? I did a simple example code in Console. Code simulates throwing dices by just pressing any key, and it does all you asked for. To make this a win application try to use this code, but it should be a lot easier, because you … | |
Re: Hi, read [URL="http://www.dreamincode.net/forums/topic/74727-more-than-one-resource-parameter-error-resolved/"]here[/URL] about it. bye | |
Re: To allow letters only subscribe to KeyPress event of textbox, and put this code inside (dont copy/paste the event, just the code inside of it): [CODE] private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { //allows backspace key if (e.KeyChar != '\b') { //allows just letter keys e.Handled = !char.IsLetter(e.KeyChar); } } … | |
Re: Is your 2nd column type of bool? Does it hav true of false values? | |
Re: [CODE] //form1 private void CreateAndCopy2DArray() { string[,] arr1 = new string[170000, 2]; string[,] arr2 = new string[170000, 20]; Form2 f2 = new Forms(arr1, arr2); f2.Show(); } //form2: public Form2(string[,] arr_1, string[,] arr_2) { //use these two variables here } [/CODE] | |
Re: Try converting data from database into soem number type, I will show you an example converting to decimal: [CODE] Dim total1 As Label = DirectCast(e.Item.FindControl("total1"), Label) total1.Text = Convert.ToDecimal(e.Item.DataItem("receivable")) * 365 / Convert.ToDecimal(e.Item.DataItem("revenue"))[/CODE] Remember, Math operations are only possible over math values (no strings involved). | |
Re: Iam not sure what exactly you want, but you can create a class variable (type of integer) and when you get the 1st for the 1s time, asign this id to this class variable. And later simply use it. If its not in any help, please provide us some code. … | |
Re: You mean that all the letters from string1 are in string2? Is so, hericles solution will work, but partly, you need a break point of the for loop, when all indexes are reached. hericles`s code needs to be modified a bit (and in VB): [CODE] Dim s1 As String = … | |
Re: try to use some more appropriate numeric checking (validation): [CODE] Dim intValue As Integer 'value in textBox is integer If Integer.TryParse(textBox1.Text, intValue) Then End If Dim decValue As Decimal 'value is decimal (in case if you use decimals If Decimal.TryParse(textBox1.Text, decValue) Then End If [/CODE] ![]() | |
Re: You can do on a very simple way: [CODE] Private Sub textBox1_KeyDown(sender As Object, e As KeyEventArgs) If e.KeyCode = Keys.Enter Then textBox2.Text = GetData(textBox1.Text.Trim()) End If End Sub Private Function GetData(str As String) As String Dim strReturn As String = "" Select Case str Case "A001" strReturn = "My … | |
Re: Write this query: [CODE]SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'[/CODE] For further info go [URL="http://www.mssqltips.com/tutorial.asp?tutorial=196"]here[/URL]. To get table name into comboBox, you can use dataReader class, and while looping through the database, add their names into comboBox: [CODE] string connectionString = @"yourConnStringHere"; using (SqlConnection sqlConn = new SqlConnection(connectionString)) … | |
Re: Try it this way: [CODE] using system; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Printing; private void Button1_Click(object sender , eventargs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage+= new PrintPage(printing); pd.Print(); } void printing(object sender , PrintPageEventArgs e) { Bitmap bitmap = new Bitmap(datagrid1.width,datagrid1.height); datagrid1.DrawtoBitmpa(bitmap,datagrid1.ClientRectangle); e.Graphics.DrawImage(bitmap,new Point(50,50)); } [/CODE] | |
Re: So you have to delete whole row in database? For each row in gridview Create new command to use DELETE query statement, like; [CODE] //initialize connection.. //initialize command.. //open connection.. string query = @"DELETE FROM MyTable WHERE FileName @param"; command.Parameters.Add("@param", SqlDbType.VarChar, 50).Value = filepath; //get file file path from the … | |
Re: Sure its possible to use Regular expressions. But you have to be specific what you have to validagte. About columns checking, do you have to check if there is the correct number of columns to suit the number of columns of dataTables (dataSet)? Best option is to use data binding. … | |
Re: To get data, you have to create a new command, using SELECT statement. | |
Re: To get the path, you have to use [I]treeView2.SelectedNode.FullPath[/I]; property. And its a bit strange to put all the files one beside another into textBox. At lease seperate them, by using some delimiter like commma: [CODE] //selected node: textBox1.Text = ReadFile(treeView2.SelectedNode.FullPath; //your method static string ReadFile(string filePath) { string ret … | |
Re: You have to subscribe to a Click event of label control: [CODE] Public Sub New() 'constructor label1.Click += New EventHandle(AddressOf label1_Click) End Sub Private Sub label1_Click(sende As Object, e As EventArgs) MessageBox.Show("label clicked.") End Sub [/CODE] | |
| |
Re: Compare both texts to "ToLower": [CODE] if (text.Contains(arr[x, 0].ToLower())) { text = text.Replace(arr[x, 0], arr[x, 1]); } [/CODE] | |
Re: You mean that only one click on a button is allowed to do the command, if there is more then one click, the message will appear? | |
![]() | Re: hi, check [URL="http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26161921.html"]here[/URL]. |
Re: Hi, this is called a floating-point number. check [URL="http://msdn.microsoft.com/en-us/library/586y06yf.aspx"]here[/URL]. | |
Re: You would like to know whats about this code you pasted in here? There is actually missing some part - the [I]StandardDie[/I] class, but its not so important (mabye for you to understand it is). Ok, - 1st you declare 5 new variables of a custom class StandardDie. - and … | |
Re: DO: [CODE] SqlConnection sqlConn = new SqlConnection("connString"); SqlDataAdapter da = new SqlDataAdapter(@"SELECT * FROM members WHERE name = @param1", sqlConn); DataTable table = new DataTable(); da.Fill(table); da.Dispose(); sqlConn.Dispose(); datagridview1.DataSource = DataTable.DefaultView; [/CODE] thats it. You will have your data in DataGridView AND Binded. So all changes in datagridview will reflect … | |
Re: Sure you can - if its in any help to use 0.0 (maybe for some comparison), but better like this: [CODE] private void yourMethod() { float = inputMethod(textBox1.Text); if(floaf == 0.0) { MessageBox.Show("Please enter a number in the account number section "); } } public float inputMethod() { float temp; … |
The End.