205 Posted Topics
Re: Have a look here: [url]www.farooqazam.net/c-sharp-auto-click-button-and-auto-fill-form[/url] Thanks | |
Re: Import "System.Xml" namespace first: [icode]using System.Xml;[/icode] And use this code to get the item name/id: [CODE] XmlDocument doc = new XmlDocument(); doc.Load("C:\\xml.txt"); XmlNodeList list = doc.GetElementsByTagName("item"); int id = 0; string name = string.Empty; foreach (XmlNode node in list) { id = int.Parse(node["id"].InnerText); name = node["name"].InnerText; Add(id, name); } [/CODE] | |
Re: You can't call class members without making an instance of it. Try adding a constructor to AppUtils class and instantiating all the array elements there: [CODE] public static class AppUtils { public static MyDogClass[] myDogs = new MyDogClass[30]; [B] static AppUtils() { for (int i = 0; i < myDogs.Length; … | |
Re: Why don't you use a method instead of a class? Add this above [I]public Form1() { ...[/I] [CODE] string FilterText(string text) { // do all the filtering here } [/CODE] And you can use it like this: [CODE] string text = "Hello, World."; text = FilterText(text); [/CODE] Thanks | |
Re: Add a braces before "private OracleDataReader GetDr(String sqltext, String ConnectionString)" | |
Re: Check my post at this thread: [url]http://www.daniweb.com/forums/post1201961.html#post1201961[/url] Thanks | |
Re: Here's a nice one: [url]http://www.csharp-examples.net/inputbox/[/url] Example use: [CODE]// this will hold the value retrieved from the input box string value = string.Empty; DialogResult result = InputBox("Username prompt", "Please enter your username:", ref value); if(result == DialogResult.OK) { MessageBox.Show(value); }[/CODE] | |
Re: Open "Program.cs" file and add this line above "Application.Run(new Form1());": [icode]Application.EnableVisualStyles();[/icode] The reason everything is looking old-fashioned is because you haven't enabled VisualStyles. | |
Re: You should use Image.FromFile(): [CODE]btnA1.Image = Image.FromFile("G:/MCL/IT126L/CircuitCreator/CircuitCreator/bin/Debug/btnWhiteBack.png"); [/CODE] Thanks | |
Re: I recommend this free book: "What the C or C++ Programmer Needs to Know About C# and the .NET Framework" [url]http://www.charlespetzold.com/dotnet/index.html[/url] | |
Re: It is going to be a little hard. Have a look here: [url]http://www.codeproject.com/KB/graphics/RectangleResizable.aspx[/url] Thanks | |
Re: Have a look at this tutorial: [url]http://www.farooqazam.net/draw-a-rectangle-in-c-sharp-using-mouse/[/url] And this thread: [url]http://www.daniweb.com/forums/post1259552.html#post1259552[/url] Thanks | |
Re: By using [icode]Main Main = new Main();[/icode], you've made a new Main form. It doesn't hold reference to the other open Main form. You are trying to close both forms which will close the application. So better use [icode]Application.Exit();[/icode]: [CODE] if (dlgResult == DialogResult.Yes) { Application.Exit(); return; } [/CODE] | |
Re: That is not the right way. You can put the code in Form_Shown event and it'll work, but the rectangle will be erased if the form is minimized, resized etc. The correct way is to use Form_Paint event. Change the drawPoint() method and add a new parameter for Graphics: [CODE]private … | |
Re: Why don't you start the form hidden? | |
Re: Trying casting it to [i]Screen[/i]: [CODE] public override void touchDown(float x, float y) { if (playbutton.isWithin(x, y)) { playbutton.touchDown(); ScreenManager.screenManager.addScreen((Screen)new ScreenPuzzleSelection(), 1); } if (helpbutton.isWithin(x, y)) { helpbutton.touchDown(); ScreenManager.screenManager.addScreen((Screen)new ScreenHelp(), 1); } if (exitbutton.isWithin(x, y)) { exitbutton.touchDown(); ScreenManager.screenManager.addScreen((Screen)new ScreenSplashExit(), 0); } }[/CODE] | |
Re: Use a generic list instead: [CODE] List<string> subj = new List<string>; for (int f = 1; f <= dir.Length; f++) { Match o = Regex.Match(txt1, "section_title='(?<TITLE>.*)'"); subj.Add(o.Groups[1].Value); } } } [/CODE] Thanks | |
Re: Textbox supports Ctrl+C and Ctrl+V by default. Do you mean to copy the text of the textbox without selecting them? | |
Re: Here's an example: Add a class-level bool variable, i.e declare it above "public Form1() { ....": [CODE][B]bool blink = false;[/B] public Form1() { InitializeComponent(); }[/CODE] Add a timer and 2 buttons to your form. Name the first button "Start" and other "Stop". Add click event for both buttons and use … | |
Re: Check these links: [url]http://www.dotnetspark.com/kb/1218-beginners-guide-to-delegates-c-sharp.aspx[/url] [url]http://compilr.com/index.php/forum/view-postlist/forum-8-cnet-tutorials/topic-22-beginners-guide-to-delegates[/url] Thanks | |
Re: You should use ILMerge to merge the dll(s) with the .exe file. ILMerge is a console application. But here's an unofficial application with GUI that's pretty easy to use: [url]http://ilmergegui.codeplex.com[/url] Thanks | |
Re: Pass "null" as an argument. Edit Program.cs: [CODE]Application.Run([B]new Form1(null)[/B]);[/CODE] And before assigning the "F" variable, check if its not a null: [CODE]if (F != null) form8 = F;[/CODE] Thanks | |
Re: You can remove a row like this: [CODE] dataGridView1.Rows.RemoveAt([B]rowIndex[/B]); [/CODE] Thanks | |
Re: You should remove the "$" sign from the text. And also, it is recommended to use Decimal data type for Money. To remove the "$" you can use [I]Replace()[/I] method: [CODE]command.Parameters.Add("@tamt", SqlDbType.Money).Value = [B]Decimal[/B].Parse(Amt.Replace("$", string.Empty); command.Parameters.Add("@oamt", SqlDbType.Money).Value = [B]Decimal[/B].Parse(OAmt.Replace("$", string.Empty);[/CODE] Thanks | |
Re: [I]Equals()[/I] method won't work for Image unless you are checking which object is it pointing to. A solution for your problem is: Declare the error image as a class-level variable (i.e declare it above public Form1() {.....): [CODE] Image errorImage = Image.FromFile("..\\..\\Images\\tbl9.jpg"); [/CODE] Now when you are assigning the error … | |
Re: How did you call that method? Can you post the code for that method call? | |
Re: I don't get what you are trying to achieve. Read this article about Drag and Drop: [url]http://msdn.microsoft.com/en-us/library/Aa289508[/url] Thanks | |
Re: You can do the trimming inside CellEndEdit event. | |
Re: You can do it like this: [CODE]SqlCommand cmd = new SqlCommand("INSERT INTO table (richTxt) VALUES('" + richTextBox1.Text + "')"); cmd.ExecuteNonQuery();[/CODE] Thanks | |
Re: You should store the "1,2,3...." in an array and then use [I]AddRange()[/I] to add it to the comboBox: [CODE] [B]string[] numbers = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; [/B] for (int i = 0; i < count; i++) { creditHours[i] = new ComboBox(); [B]creditHours[i].Items.AddRange(numbers);[/B] … | |
Re: The reason it returned "4" instead of "0" was because when you entered "70". It was smaller than "73" so sCategory was assigned "0". But it is also smaller than "95" which made sCategory "1". The next if statement made it "2" because it is also smaller than "110" and … | |
Re: You have added an unexpecting comma ',' after [icode]& txtmsg.Text & "'[/icode]. Try removing that. [CODE] sql = "Insert into contact (fname, email, msg) values ('" & txtname.Text & "', '" & txtmail.Text & "', '" & txtmsg.Text & "')" [/CODE] | |
Re: To restart the application, use: [icode]Application.Restart();[/icode] Thanks. | |
Re: I am not sure but I've tried something that seem to work: Set your webBrowser Uri to "about:blank" (or use any other url you want). And add "DocumentComplete" event for your webBrowser. Add this to the DocumentComplete event: [CODE] webBrowser1.Document.MouseUp += new HtmlElementEventHandler(Document_MouseUp); [/CODE] Put a MessageBox (for testing) inside … | |
Re: The GetPixel() method is better. Because it won't read all the pixels if there's a difference while the other method will always read both the files. | |
Re: Why do you want to keep FormR hidden instead of closing it? | |
Re: When you are adding a single item (not an array) use [I]Add()[/I] and when you are using an array use [I]AddRange()[/I]. Working version of your code: [CODE] string transfer = shiftTypeIn[0]; checkedListBox1.Items.Add(transfer) string transfer2 = shiftTypeIn[1]; checkedListBox1.Items.Add(transfer) [/CODE] Thanks | |
Re: Use this: [CODE] if(buttonX4.InvokeRequired) { this.Invoke((MethodInvoker)delegate() { buttonX4.Text = "Copy To Clipboard"; }); } [/CODE] | |
Re: You should add a new class [I]Person[/I] and use a generic list. Here's an example: [CODE] using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication { class Program { static void Main(string[] args) { [B]List<Person> people = new List<Person>();[/B] string salary, pno, pcode, state, addr, strno, name; Console.WriteLine("enter salary:"); salary = … | |
Re: Set "EditMode" for the datagridview to "EditProgrammatically". Use this for the "Edit" button: [CODE] dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; [/CODE] If you have a "Read Only" button the use this: [code] dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically; [/code] Thanks | |
Re: Hello Sadaf, Here's an example: Use this when opening Form2: [CODE] Form2 form2 = new Form2(textBox1); form2.Show(); [/CODE] Edit form2 and make it like this: [CODE] TextBox txtBox; public Form2(TextBox txtBox) { InitializeComponent() this.txtBox = txtBox; } // Now you can get form1's textbox text like this private void button1_click(object … | |
Re: [QUOTE=;][/QUOTE] You have used "1" as the starting index in the for loop. You should use "0". Try this: [code] for (int r = 0; r < dt.Rows.Count; r++) { ..... }[/code] Thanks | |
Re: Add "FormClosing" event to your form. And use this code: [CODE]private void Form_Closing(object sender, FormClosingEventArgs e) { // Remove these 2 lines if the current form is not the default form of your application. e.Cancel = true; this.Hide(); LoginForm loginForm = new LoginForm(); loginForm.Show(); }[/CODE] Thanks | |
Re: Use this: [CODE] int i = (int)dataGridView1.Rows[e.RowIndex].Cells["yourUniqueID"].Value; [/CODE] Thanks | |
Re: If the login windows is the default Form of your application then you should hide it. Because if you close it it'll close the application. Here's an example: [CODE] if (userName_login_window.Equals("1") && pass_login_window.Equals("2")) { MainWindow window = new MainWindow(); window.ShowDialog();//Brings up the main window [B]this.Hide();[/B] } [/CODE] | |
Re: The problem might be with the [I]arr(i)[/I] values. Have you tried checking what those values (X & Y) returns? | |
Re: Here's an example: [B]MainForm:[/B] [CODE] // Make it "public" so we can access it from LoginForm public bool loggedIn = false; LoginForm form2; public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { // Disable the menuStrip menuStrip1.Enabled = false; // Initialize Form2 and pass "MainForm" as an … |
The End.