1,469 Posted Topics
Re: You would have to add a DataGridViewRadioButtonColumn, either in designmode or at runtime. Use the CustomDataGridView instead of the DataGridView when you design the form. [CODE] public class DataGridViewRadioButtonColumn : DataGridViewTextBoxColumn { internal const int radioButtonSize = 14; public DataGridViewRadioButtonColumn() :base() { this.ReadOnly = true; } internal static void Paint(Graphics … | |
Re: You can do: [CODE] string query1 = @"update trainn set Adultno=Adultno-1 where ID=@pram1 and adult=@pram2 and Adultno>0"; string query2 = @"update trainn set childno=childno-1 where ID=@pram1 and child=@pram2 and childno>0"; string[] queriesArray = new string { query1, query2 }; foreach(string query in queriesArray) { sqlCmd = new SqlCommand(); sqlCmd.Connection = … | |
Re: Do you want to create a DataBase out of these data? I think it would be good, and then create some classes, like Student, Class, and so on if needed. It would still be good if you tell us more what are you trying to do, a complete application for … | |
Re: So create a new table, and inside of it create some columns: AbsenceID, StudentFK, Date. This means each row will have its only id (primary key), foreign key to the Students table, and an actual absendce date. So you will have this kind of structure: [CODE] Student: StudentID, Name, Age,... … | |
Re: LOL, there is no such thing! Sorry, you came on the wrong place. Best way to get knowledge is to try to use it in practice. SO has a plenty of questions about C# books/sites/tutorials. Learning pattern is really simple: read a little bit of information on C# and try … | |
Re: Do you get any data into DataTable? Use a break point, hover the mouse ovher "dat" variable, and click on Magnifying glass to see if there is any data inside. If its not, your query is not corrct, or database is empty. Check that 1st. | |
Re: What exactly would you like to do? Can you give us an example? | |
Re: hi, yes it would be good if you explain this a bit better. I have a few ideas of what do you want, but I will not go and describe all here now. So.. | |
Re: Yes, you have to clear dataSet (or dataTable in case if you dont have dataSet). | |
Re: Hi, you can check it [URL="http://www.daniweb.com/software-development/csharp/threads/361478"]here[/URL]. And btw, if you figure it out, can you please share your working code with us? thx in advance. | |
Re: Momerath is saying you cannot multiply some double value with double array value. No go. You have this code: [CODE]double [] perminuterate = { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };[/CODE] What are these numbers mean? And you have to select ONLY one value from this double array to multiply … | |
Re: I would rather suggest you to use generic list<T>. But if you insist uisng string array, you can do it in this way too: [CODE] string[] array = new string[7]; //reading port and fill the array! //then you can do: string delimiter = ";"; //and write to a file: string … | |
Re: As Momerath said, please tell us what do you want to have in textBoxes, otherwise here is a simple example of a textBoxes array and a loop to insert text into them: [CODE] TextBox[] tbs = new TextBox[] {textBox1, textBox2, textBox3 }; //put all of them in here! //then loop: … | |
Re: Where do you have: [CODE]SqlConnection sqlConn = new SqlConnection("connString");[/CODE] amd for to Read data, you have to opean a connection as well: [CODE]sqlConn.Open();[/CODE] And its good to close it on the end of the code (or use "using" keywords instead). | |
Re: YOu have to set some more parameters, like position (Location), size (if necessary), name, ...: [CODE] //inside click event handler string submitWord = tempWord; Label lbl = new Label(); lbl.Name ="label1"; lbl.Text = submitword; lbl.Location = (20, 20); //set your location lbl.AutoSize = true; flowLayoutPanel.Controls.Add(lbl); [/CODE] | |
Re: You have to define which value to put into an array. This is happening in 12. row of your code. Try to change the code into: [CODE] Console.WriteLine("enter the limit:"); int n = int.Parse(Console.ReadLine()); int[] str = new int[n]; for (int i = 0; i < n; i++) { str[i] … | |
Re: The code looks ok to me. What values do you have in origianl array? Just one thing to clear it out: If you have two arrays declared on the class level, then you do not need to use return and creating other arrays in methods inside of this class. Because … | |
Re: As said, use Math.Round method. 1st parameter in this method in the actual value you want to round, while 2nd parameter is the number of decimals. If you will do as Luc001 showed, will do just fine or: [CODE] Dim dValue As Decimal = 0D If Decimal.TryParse(textBox1.Text.Trim(), dValue) Then textBox2.Text … | |
| |
Re: use SelectedItem property of comboBox: [CODE] comboBox1.Selecteditem.ToString(); [/CODE] | |
Re: One of the possibilities is to use TextChanged event handler: [CODE] private void textBox1_TextChanged(object sender, EventArgs e) { string lastChar = textBox1.Text.Substring(textBox1.Lenght -1, 1); if(lastChar == " ") { MessageBox.Show("User has just pressed spaceBar."); } } [/CODE] Or use can use KeyPress event, where you will get the last character … | |
Re: Ok, I did the whole code you wanted. The code can Export and Import data from CS file. It even creates columnHeader text: [CODE] Public Partial Class Form1 Inherits Form Public Sub New() InitializeComponent() 'creating columns: dataGridView1.Columns.Add("col1", "Id") dataGridView1.Columns.Add("col2", "Name") 'allowing that user can add new rows: dataGridView1.AllowUserToAddRows = True … | |
Re: Change this method to: [CODE] private void AddListBoxItem(object item) { if (this.ConvBox.InvokeRequired) this.ConvBox.Invoke(new AddListBoxItemDelegate(AddListBoxitem), new object[] {item}); else this.ConvBox.Items.Add(item); } [/CODE] | |
Re: Try it this way: [CODE] For i As Integer = 0 To ListBox1.Items.Count - 1 Dim lstitem As String = ListBox1.SelectedItem.ToString() Dim sqlQuery As String = "UPDATE laitemtype SET IsActive = @active WHERE itemtypedescription=@lst" Dim cmd6 As New SqlCommand(sqlQuery, Con) 'I hope oyu have created a new instance of SqlConnection … | |
Re: Exactly. In your particular case you do: [CODE] this.Controls.Add(TxBxArray[i]); [/CODE] | |
Re: Check for them here: [URL="http://www.connectionstrings.com/"]http://www.connectionstrings.com/[/URL] | |
Re: This will do it: [CODE] public partial class Form1 : Form { Label[] lbls; public Form1() { InitializeComponent(); char[] letters = Enumerable.Range('A', 'Z' - 'A' + 1).Select(i => (Char)i).ToArray(); lbls = new Label[letters.Length]; int x = 20; int y = 20; for (int i = 0; i < letters.Length; i++) … | |
Re: You are doing incorrect update statement. On the right side of the equl mark you have the parameter, which you then have to specify in the command, like: [CODE] var cmd = new OleDbCommand("UPDATE Resources SET Image= @a WHERE ResourceName= @b", conn); cmd.Parameters.Add("@a", OleDbType.VarChar).Value = listView.SelectedItems[0].Tag; cmd.Parameters.Add("@b", OleDbType.VarChar).Value = _username; … | |
Re: Hi, would you mind sharing the solution? thx in advance. | |
Re: Hi, take a look at here how this has to be done: [url]http://www.dotnetspider.com/resources/5069-Writing-DataTable-into-text-file.aspx[/url] | |
Re: [CODE] public partial class Form1 : Form { Timer timer1; Button[] btns; public Form1() { InitializeComponent(); timer1 = new Timer(); timer1.Interval = 1000; timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); //create an array of buttons: btns = new Button[] { button1, button2, button3 }; } protected override void OnShown(EventArgs e) { //set … | |
Re: This is the parameter you have issues, right?: [CODE]da.Parameters.Add("@Available", SqlDbType.Bit).Value = textBox7.Text;[/CODE] Bit can only have "true" or "false" values in th database. What is your value in textBox7? Its you have 1 or 0 do a conversation to true or false. EDIT: and instead of textBox6, in which you … | |
Re: You dont need to use StringBuilder class as array. You can simple do: REMEBER: before putting bytes into stirng, you will have to convert it, otherwise you will not get the correct result!! [CODE] private string Byte_To_Hex_Ar(Byte[] data) { StringBuilder sb = new StringBuilder(); foreach (byte b in data) { … | |
Re: Is maybe this what you have been looking for: [CODE] int[,] array = new int[2, 4] { { 1, 2, 3, 4 }, { 1, 2, 3, 4 } }; List<int> list = new List<int>(); for (int i = 0; i < array.GetLength(1); i++) { int sum = 0; for … | |
Re: He is going to some Informatics school He has no other obligations (but I mean real obligations, not some strange sport activity) And he has no time for HIS school project which should be on 1st place of all orders. Strange is this world today! But it sure wasn`t in … | |
Re: Hi, try it this way: [CODE] public class testing { delegate void mydelegate(string msg); public void btnStart_Click(object sender, EventArgs e) // Click Event { ThreadStart ts = new ThreadStart(StartServer); Thread t = new Thread(ts); t.Start(); } public void StartServer() { str = "Hello"; function1(str); } public void function1(string str) { … | |
Re: YOu didnt start coding the correct way. You have to put buttons into an array, and loop through them and create a common event for them, like this: [CODE] //on form load on in constructor: Button[] btns = new Buttons[]{button1, button2, button2, button4, button5, button6, button7, button8 }; foreach(Button btn … | |
Re: Does your DataTable get filled up with data from dataBase? Use a break point to "stop" the code, and then go with F11 key forward row by row, and with hovering mouse over some value (varible), you will see if there are data inside of it). | |
Re: Hi, you can do it this way: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); listView1.Columns.Add("column 1", -2, HorizontalAlignment.Left); listView1.Columns.Add("column 2", -2, HorizontalAlignment.Left); listView1.View = View.Details; PopulateListView(); } private void PopulateListView() { DataTable table = GetDataFromDB(); for (int i = 0; i < table.Rows.Count; i++) { … | |
Re: Here: [CODE] private void Form5_Load(object sender, EventArgs e) { DataGridViewComboBoxColumn cmbcolumn = new DataGridViewComboBoxColumn(); cmbcolumn.Name = "cmbColumn"; cmbcolumn.HeaderText = "combobox column"; cmbcolumn.Items.AddRange(new string[] { "item1", "item2", "item3" }); //here you can even use dataBinding! dataGridView1.Columns.Insert(1, cmbcolumn); //or add: dgv.Columns.Add(cmbcolumn); dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing); } private void dataGridViewEkipe_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) … | |
Re: How about doing game in C#? I did some simple games, like card games, but I would like to do something bigger. A real game. Is C# appropriate? | |
Re: Would you mind writing the question in words? So we can all understand what are you trying to do? | |
Re: If you have a login, I assume you use a database, where you save users name and passwords (and other informations). If so, you can create a new column in the Users table, which will save the information about "[I]saving user`s name[/I]". You need only two states - true, or … | |
Re: Hi, I didnt get you well. You need to create a NEW folder some where on hdd to store your dataBase inside of it, Am I right? | |
Re: try changing the connect string of ConfigurationManager to: [CODE]string connect = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;[/CODE] All the rest stays the same. If the connection string is correct, this has to work. | |
Re: Here, I did the code you would like to have. There is maybe some work to be done in the cell vadidating (data validation; if email and tel.number are correct), and this is about it. When you do some changes, you press one button, and all it saves automatically (or … | |
Re: You cannot access to AppendText or any property of TextBox over threads. You will have to use delegates to access to it on controls, not on your do, while loop: [CODE] namespace sync { public partial class Form1 : Form { int s = 0; delegate void MyDelegate1(string msg); delegate … | |
Re: Hi, does the code of adding new row to the dataTable works? I think it does, the code you posted looks ok. Would you mind posting the whole code, including SELECT sql statement? | |
Re: If there is really alot of data, which will be a time consuming action, you can create a new thread (or use BackGroundWorker, which is a new thread too), and use Sort method: [CODE] string [] array = {"some values in array"}; Array.Sort(array);[/CODE] | |
Re: You will have to use delegates to update the Text property of the label1. Because you want to access from another thread to the main one and update the label`s Text property, you get this error. You can do it like this: [CODE] //delegate void MyDelegate(string message); private void MyMethod(string … |
The End.