1,469 Posted Topics

Member Avatar for Kath_Fish

Check out this code: [CODE] private void buttonWrite_Click(object sender, EventArgs e) { List<string> list = new List<string>(new string[] { "a,", "b", "c" }); //out put example CreateAndWriteIntoFile(list); } private void buttonRead_Click(object sender, EventArgs e) { List<string> list = ReadFromFile(); } private void CreateAndWriteIntoFile(List<string> list) { string path = @"C:\MyFolder\myFile.txt"; using …

Member Avatar for Mitja Bonca
0
102
Member Avatar for AngelicOne

I did an example code which populates dgv from a dataSet, and then gets the selected row`s data, and passed them to form2`s textBoxes. In my example I only have 2 column in the dataSet (as in dgv of course) and 2 textBoxes to populate on form2. Take a look, …

Member Avatar for Mitja Bonca
0
206
Member Avatar for moshe12007

Try doing a loop through foreach control of the form: [CODE] private void Insert() { foreach (Control c in this.Controls) { if (c is TextBox && c != null) { string valueOfTextBox = c.Text; } } } [/CODE]

Member Avatar for moshe12007
0
169
Member Avatar for spunkywacko

This should do it: [CODE] public partial class Form1 : Form { private int wordIdFunc; public int propWordId { get { return wordIdFunc; } set { wordIdFunc = value; } } public Form1() { InitializeComponent(); } public string Word() { string[] words = new string[4]; words[0] = "The"; words[1] = …

Member Avatar for ddanbe
0
100
Member Avatar for Usmaan

Check it out here: [url]http://www.dreamincode.net/forums/topic/58021-deploying-a-c%23-application-visual-studio-setup-project/#-application-visual-studio-setup-project/[/url] Mitja

Member Avatar for Mitja Bonca
0
95
Member Avatar for AngelicOne

For having images in the listView (on in some other control), best way is to use an ImageList. You put images inside, and from there show images in listView. For example, how to get images form a disc, send then to imageList and then to listView: [CODE] //for better accurecy …

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

Sure, you cannot show an array in a messageBox (its like putting a string array into stirng - cant do). You have to get all values from an array into a string, then show it in messageBox: [CODE] string[] myname = new string[2]; myname[0] = "Shahid"; myname[1] = "Hussain"; string …

Member Avatar for yousafc#
0
92
Member Avatar for Kath_Fish

Foreach is a loop. So you cannot assign it to read for one string. You did like: [CODE] string a = "a"; foreach(string b in a){} //this is an error! [/CODE] You have to do it like: [CODE] string[] array = {"a", "b"}; foreach(string b in array) { //get each …

Member Avatar for Kath_Fish
0
138
Member Avatar for jugnu

[QUOTE=jugnu;1491997]The problem is when i edit a record and the SelectedIndex of TabControl is not TabPage 3 and when i save the record without moving to TabPage 3 i receive an error shows that Input String was not in Correct Format. But when i move to that TabPage i receive …

Member Avatar for Mitja Bonca
0
154
Member Avatar for Farhad.idrees

Try using SelecredIndices collection: [CODE] public Form1() { InitializeComponent(); //my test population: char[] array = "abcdef".ToCharArray(); for (int i = 0; i < array.Length; i++) listBox1.Items.Add(array[i]); listBox1.SelectionMode = SelectionMode.MultiExtended; } private void button1_Click(object sender, EventArgs e) { while (listBox1.SelectedIndices.Count > 0) listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]); } [/CODE]

Member Avatar for ddanbe
0
200
Member Avatar for ajinkya112

How will dataSet show some value from it, if its empty. YOu have to retrieve the value from dataSet to textBox, after its being populated. So put the code from 4th line, bellow the line where you do the filling ("Fill()" method). If this is not it, tell more about …

Member Avatar for Mitja Bonca
0
132
Member Avatar for vasuhajare@gmai

Tabular? Whats is this? Does the dataGridView control satisify your expectations? So, back to your issue. Get wanted values from database( use DataTable to fill it up), then open Form2 (new pop-up window) and pass dataTable parameter to it (it can be passed in the constructor of form2). Then bind …

Member Avatar for Mitja Bonca
0
696
Member Avatar for ajinkya112

As darkagn said. Heres an example: [CODE] private void PopulatingTextBoxes() { int id = GetNewId(); textBox1.Text = id.ToString(); } private int GetNewId() { int id = 0; using (SqlConnection sqlConn = new SqlConnection("ConnectionString")) { string query = "SELECT (MAX)ID FROM STU"; SqlCommand cmd = new SqlCommand(query, sqlConn); using (SqlDataReader reader …

Member Avatar for Mitja Bonca
0
345
Member Avatar for Usmaan

Something lke that? [CODE] private void method() { const int value = 5; string tag = "_"; string item = ""; for (int i = 0; i < value; i++) item += tag; MessageBox.Show("You have chosen " + value.ToString() + " underscores.\nThe result is: \"" + item + "\""); } …

Member Avatar for Momerath
0
119
Member Avatar for james6754

I have changed the code a bit, with using virtual and override. And did some small changes also. Take a look: [CODE] class Program { static void Main(string[] args) { Student s = new Student("Dave", 1234); s.Birthday(); s.Print(); Console.ReadLine(); } } class Person { protected string name; protected int age; …

Member Avatar for Momerath
0
94
Member Avatar for Usmaan

Try this: [CODE] private void method() { Random r = new Random(); string[] colors = { "blue", "red", "purple", "pink" }; string color = colors[r.Next(colors.Length)]; } [/CODE]

Member Avatar for Momerath
0
3K
Member Avatar for kimmi_baby

Momerath already showed you how to use properites. This how you have to do: [CODE] public partial class Form1 : Form { private int n; public int N { get { return n; } } public Form1() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; } public void Increment() { n = n …

Member Avatar for lianpiau
0
109
Member Avatar for pramod90786
Member Avatar for Jessurider

Hi, go to form designer, click on form, so the form`s border will have the focus. Now go to Properties window. There you will see a property called Icon. Select it, and click on button on the right. The "OpenFileDialog" will open and simpy look for your icon, and click …

Member Avatar for lianpiau
0
90
Member Avatar for Usmaan

You can hind Form1, and open form2. [CODE]//on button click: Form2 f2 = new Form2(); this.Hide(); f2.Show();[/CODE] If you will close or dispose Form1, the whole application will close, thats because in Program class you called "Application.Run(new Form1());" so this holds up everything.

Member Avatar for Usmaan
0
93
Member Avatar for Usmaan

No where. You can simply use an usual method, instead of cnstructor. Something like: [CODE] //on class1: Class2 c2 = new Class2(); c2.DoOnBeginning(); //on Class2: class Class2 { pubic Class2() { //constructor of class2 (its empty - but in use now) } public void DoOnBeginning() { //do some code! } …

Member Avatar for Mitja Bonca
-1
202
Member Avatar for Jessurider

Why dont you simple paste the code in here? And add some of descrition about the issue? Please... every one does that. Mitja

Member Avatar for Jessurider
0
59
Member Avatar for 303factory

Or you can try this: [CODE] int index = 1; Array list = Enum.GetValues(typeof(sourceType)); string value = list.GetValue(index).ToString(); [/CODE] Mitja

Member Avatar for 303factory
0
112
Member Avatar for AngelicOne

[QUOTE=AngelicOne;1487956]There's an error saying that the combobox is already b, inded to a datasource, thus cannot add new items. [/QUOTE] Add items to a dataSource, not to comboBox. When you have some control bind to a data source, you have to work then with the data source (inserting, updating, removing), …

Member Avatar for Mitja Bonca
0
360
Member Avatar for Kath_Fish

What is it that you want to split the string? Do you want to get all words into an array?

Member Avatar for Kath_Fish
0
327
Member Avatar for Behseini

Hi, it seems your connection string is not the right one. Have you checked [URL="http://connectionstrings.com/oracle"]here[/URL] for it? And are you sure about your parameters enters into connection string? Are defenatelly the right one?

Member Avatar for Behseini
0
159
Member Avatar for hmnetonline

Hi, would you mind describling your issue a bit better? I really dont understand what would you like to achive. But somehow I would say choosing Buttons for this task isnt the right option. Have you thought of what Momerath has proposed to you? If you think differently, please go …

Member Avatar for Mitja Bonca
0
136
Member Avatar for AngelicOne

Look at this code, it removes the duplications: [CODE] public partial class Form1 : Form { DataSet ds; public Form1() { InitializeComponent(); CreatingDS(); } private void CreatingDS() { ds = new DataSet(); DataTable table = new DataTable("MyTable"); table.Columns.Add("id", typeof(int)); table.Columns.Add("name", typeof(string)); string[] names = { "A", "B", "C", "A", "B" …

Member Avatar for Mitja Bonca
0
101
Member Avatar for johnt68
Member Avatar for Kath_Fish

Do you want to use a MultiLine textBox? If so, here is your answer: [CODE] public Form1() { InitializeComponent(); textBox1.Multiline = true; textBox1.ScrollBars = ScrollBars.Vertical; Method(); } private void Method() { int[] array = { 1, 2, 3, 4, 5 }; foreach (int value in array) textBox1.AppendText(value.ToString() + Environment.NewLine); } …

Member Avatar for Kath_Fish
0
332
Member Avatar for Kath_Fish

[QUOTE=Kath_Fish;1487225]hey...i want to ask about how to convert string array to integer array. hope someone can help me. thanks.[/QUOTE] As long as the strings are only numbers (no commas or dots indside the string), you can convert the string into integer as Momerath shows abouve. Mitja

Member Avatar for Mitja Bonca
0
214
Member Avatar for arsheena.alam

Hi, your code looks pretty strange, especially the using(xxx) row, but I dont know what those variables mean, so hard to tell... Lets make it a bit different: [CODE] private void DeletingDataBase() { using (SqlConnection sqlConn = new SqlConnection("ConnectionString")) { using (SqlCommand cmd = new SqlCommand()) { string sqlQuery = …

Member Avatar for arsheena.alam
0
2K
Member Avatar for brite_a

You need to use delegate, look at this my example: [CODE] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Feb27Exercise1 { public partial class Form1 : Form { System.Threading.Thread thread; delegate void TextBoxDelegate(string message); public Form1() { InitializeComponent(); } private void …

Member Avatar for brite_a
0
5K
Member Avatar for drspock

Row height: [CODE] foreach (DataGridViewRow row in dataGridView1.Rows) row.Height = 30; [/CODE]

Member Avatar for Mitja Bonca
0
88
Member Avatar for davieJohnson

Hi, check here: [url]http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_24657018.html[/url]

Member Avatar for davieJohnson
0
212
Member Avatar for Dasharnb777

[CODE] private static void Test() { List<string> list = new List<string>() { "A", "B", "C" }; IList<IList<string>> perms = Permutations(list); foreach (IList<string> perm in perms) { foreach (string s in perm) { Console.Write(s); } Console.WriteLine(); } } private static IList<IList<T>> Permutations<T>(IList<T> list) { List<IList<T>> perms = new List<IList<T>>(); if (list.Count …

Member Avatar for Momerath
0
2K
Member Avatar for spunkywacko

I still dont get it what you want to do. Please explain in some words what is your intention. Why is an array there, what do you put into it? Is it filled in the runtime (in the code), or does it fill from textBox (or some other control)? Why …

Member Avatar for jameslittle2104
0
153
Member Avatar for Behseini

Size is a read only property. Use Width and Height directly, Size is just a helper property if you need them as a Size object. [CODE] Form1 f = new Form1(); f.Height = 400; [/CODE]

Member Avatar for Behseini
0
119
Member Avatar for Kath_Fish

:) Check this out man: [CODE] private void method() { string allText = "1, 2, 3, 4, 5\n2, 3, 4, 5"; allText = allText.Replace(",", ""); string[] lines = allText.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); Dictionary<int, List<int>> dic = new Dictionary<int, List<int>>(); for (int i = 0; i < lines.Length; i++) …

Member Avatar for Momerath
0
210
Member Avatar for Behseini

My this code: [CODE] while (reader.Read()) { if(reader.GetValue(0) != DBNull.Value) listAtt.Items.Add(reader.GetValue(0).ToString()); //or better coding to get value: //listAtt.Items.Add((string)reader[0]); } [/CODE] This should do it. Mitja

Member Avatar for Mitja Bonca
0
546
Member Avatar for liam0014

Look at this code how it should be done: [CODE] public partial class Form1 : Form { List<string> list; BindingList<string> bindingList; public Form1() { InitializeComponent(); string[] array = new string[] { "A", "B", "C" }; list = new List<string>(array); bindingList = new BindingList<string>(list); listBox1.DataSource = bindingList; listBox1.SelectedIndex = -1; } …

Member Avatar for Mitja Bonca
0
5K
Member Avatar for McvR

You have to get the x,y location point of the control above.Then add to the "y" the height of this control and + 20. In my example, your new Control is my label, and my listBox is your BerichtInput: [CODE] int x = listBox1.Location.X; int y = listBox1.Location.Y; y = …

Member Avatar for ddanbe
0
181
Member Avatar for moose333

Hi, You can use StreamReader to read rows, and the code will look like this: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { List<string> list = GetDataFromFile(); richTextBox1.Clear(); foreach (string item in list) richTextBox1.AppendText(item + Environment.NewLine); } private …

Member Avatar for Mitja Bonca
0
167
Member Avatar for Chellam2

You can see into this example code how it has to be done: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); Text[] arrayOfText = new Text[3]; string[] array = new string[] { "A", "B", "C" }; //Adding int Text Array: for(int i=0;i<arrayOfText.Length;i++) { arrayOfText[i].someText = array[i]; …

Member Avatar for Mitja Bonca
0
351
Member Avatar for ajinkya112

I have an example code with a bit different approach: [CODE] //form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); string[] array = new string[] { "A", "B", "C" }; this.comboBox1.Items.AddRange(array); this.comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); } private void comboBox1_SelectedIndexChanged(object obj, EventArgs e) { string item = comboBox1.GetItemText(comboBox1.SelectedItem); …

Member Avatar for Mitja Bonca
0
127
Member Avatar for samreen36

Hi, and welcome to programming. About your question, you have to give us an idea of what would you like to do. Then we`ll help you out. Mitja

Member Avatar for Mitja Bonca
0
117
Member Avatar for AngelicOne

I will only add to ddanbe` post: If you are not in some dgv`s event handler you get the row number like: [CODE] private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { int rowIndex1 = e.RowIndex; int rowIndex2 = GetRowIndex(); } private int GetRowIndex() { int rowIndex = this.dataGridView1.CurrentCell.RowIndex; return rowIndex; } …

Member Avatar for Mitja Bonca
0
799
Member Avatar for jotae
Member Avatar for Mitja Bonca
0
85
Member Avatar for nutrion

I will show some other way of using Threads and using boolean variable to stop it! Using thread.Abort() method is not a graceful way of stoping the thread. Not that its not correct (it does what its meant for), but there is a better any more appropriate way, as said, …

Member Avatar for Mitja Bonca
0
118
Member Avatar for Jessurider

btw, why do you need a timer in the code? I did what I thought you want. Tell me if this is it. [CODE] int sRight; int sLeft; public MainForm() { InitializeComponent(); this.KeyDown += new KeyEventHandler(MainForm_KeyDown); } private void MainForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right) { if …

Member Avatar for prvnkmr194
0
99

The End.