- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 339
- Posts with Upvotes
- 312
- Upvoting Members
- 135
- Downvotes Received
- 22
- Posts with Downvotes
- 20
- Downvoting Members
- 13
... I only want to learn programming decently!
That`s about it.
- Interests
- tennis, football, skiing, karting
Re: Use this: Imports System.Runtime.InteropServices Imports System.Text Namespace Ini ''' <summary> ''' Create a New INI file to store or load data ''' </summary> Public Class IniFile Public path As String <DllImport("kernel32")> _ Private Shared Function WritePrivateProfileString(section As String, key As String, val As String, filePath As String) As Long End … | |
Re: back to topic question: [CODE] //constructor: public Form1() { this.button1.Visible = false; } private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) this.button1.Visible = true; else this.button1.Visible = false; } [/CODE] | |
Re: Is your DGV bind to dataSource? If so you can do a filter with "SUM Columns", which will ack like an sql query. If you dont use any dataSource, you can loop through rows and sum cell in this partiucular column, like: [CODE] decimal total = 0; foreach (DataGridViewRow row … | |
Re: YOu have to be aware of one thing: when you close the form (main form you named it), which has been started from Program class with: Application.Run(new Form1()); The application will close. To avoid this, you have to take care of closing all other form before this one. | |
Re: I would rather choose KeyPress event, where you can use "e" parameter and set its Handled property: [CODE] Private Sub textBox1_KeyPress(sender As Object, e As KeyPressEventArgs) If textBox1.Text.Length >= 10 Then If e.KeyChar <> ControlChars.Back Then e.Handled = True End If End If End Sub [/CODE] | |
Re: YOu cannot read a whole row of the dgv to a string. Ok, you can, but there will be no value you want to have. So you have to specify from which column and from which row you want to get the value. Lets repair your code: [CODE] //just make … | |
Re: Try this: [CODE] string a = "12.34"; decimal b = Convert.ToDecimal(a, System.Globalization.CultureInfo.InvariantCulture); [/CODE] | |
Re: I would rather put the code which is not in the button Click event into a new method. Then you call this method in button clck in that form, and from another form, like: [CODE] //other form whih has a button click event: private void button_Click() { MethodToExecute(); } public … | |
| Re: string myEnum =MyEnum.A.Tostring(); |
Re: I`m afraid not. There is plenty of data to save. You can create a progressBar, which will show the progress of saving, and create a new thread which will do the saving (and restoring data back to richTextBox). Btw: but even the type varchar should do it. Maybe you didn`t … | |
Re: Add a new class into your project and paste this code: [CODE] Imports System.Windows.Forms Public Class BetterListBox Inherits ListBox ' Event declaration Public Delegate Sub BetterListBoxScrollDelegate(Sender As Object, e As BetterListBoxScrollArgs) Public Event Scroll As BetterListBoxScrollDelegate ' WM_VSCROLL message constants Private Const WM_VSCROLL As Integer = &H115 Private Const SB_THUMBTRACK … | |
Re: Check out this way by using DialogResult (and passing data between forms or classes): 'PROGRAM class Class Program ''' <summary> ''' The main entry point for the application. ''' </summary> <STAThread()> _ Private Shared Sub Main() Application.EnableVisualStyles Application.SetCompatibleTextRenderingDefault(false) Dim loginData As String = "" Dim l As Login = New … | |
Re: Try to bind data. I mean, fill dataTable and bind it to dgv: [CODE] //retreive data from db to datatable: SqlDataAdapter adpat = new SqlDataAdapter(); adpat.SelectCommand = new SqlCommand("select * from ImgTB", con); DataTable table = new DataTable("myTable"); adpat.Fill(table); //create image column: DataGridViewImageColumn photoColumn = new DataGridViewImageColumn(); photoColumn.DataPropertyName = "Picture"; … | |
Re: Here is my example code (which i did some time ago) and actually used is some where: [CODE] Public Shared Function NumberToWords(number As Integer) As String If number = 0 Then Return "zero" End If If number < 0 Then Return "minus " & NumberToWords(Math.Abs(number)) End If Dim words As … | |
Re: I actually dont understand what is wrong with your code based on your description. Do you want to try to add text from some other class to textbox? | |
| Re: private List<string> list = new List<string>(); public List<string> List { get { return list; } set { list = value; } } |
Re: Check out this code. The 1st part is only a simple dgv population. Then is the code which color the rows: [CODE] public Form1() { InitializeComponent(); dataGridView1.Columns.Add("col1", "column 1"); dataGridView1.Columns.Add("col2", "column 2"); dataGridView1.Rows.Add(1, "Canceled"); dataGridView1.Rows.Add(2, "Ok"); dataGridView1.Rows.Add(3, "Canceled"); dataGridView1.Rows.Add(4, "Canceled"); dataGridView1.Rows.Add(5, "Ok"); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1["col2", … | |
| Re: Why would you have drives in seperated combo? Wouldn`t be better to have all in treeView? |
Re: Get all the textBoxes into an array, and read them (using Text property) into a StringBuilder class. Then write all to a text file: [CODE] Textbox[]tbs = { textBox1, textBox2, textBox3 }; // add all of them in here StringBuilder sb = new StringBuilder(); foreach(TextBox tb in tbs) sb.AppendLine(tb.Text); System.IO.File.WriteAllText(@"C:\myFile.txt", … | |
Re: No, you have to put the instance of the Random on the class level, then you will not have problems with getting random number every where (on load event, or on some button click event, or in some method): [CODE] //form1 class: Random r = new Random(); public Form1() { … | |
Re: Iam affraid you cannot put images into a listBox (without any additional hacking of the code). I would better suggest you to use ListView, which is meant for it.8df **Images to lsitview:** If you want to do this in the designer, you can take the following steps to add the … | |
Re: Me neither :) List<T> is best option. Maybe for some "simple" arrays its better to use a simple array, like string[], or int[]. But if you have a custom object, List is better choice, and even better is a generic list (List<T> - as Momerath described in the previous post). | |
Re: This is another version of updating Label`s text over the thread: [CODE] delegate void LabelDelegate(string message); public Form1() { InitializeComponent(); } private void UpdatingLabel(string msg) { if (this.label1.InvokeRequired) this.label1.Invoke(new LabelDelegate(UpdatingLabel), new object[] { msg }); else this.label1.Text = msg; } [/CODE] Its faster and easier... | |
Re: You can create a new connection from Server Explorer and copy connection strings from properties in your project. Following link contains steps to create connection from Server Explorer [url]http://msdn.microsoft.com/en-us/library/s4yys16a(v=VS.90).aspx[/url] You can try following Connectionstring Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; You can also get list of connection string from [url]http://connectionstrings.com/sql-server-2008[/url] ---------------------------------------------------------------------------------------------------- Do … | |
Re: Hi, I would recommend you to fill DataTable from DGV, but there is still not in-built way to do so. check this link: http://stackoverflow.com/questions/4720463/how-to-export-from-datatable-to-pdf-in-wpf | |
Re: Did you bind the listBox1, using DataSource property from DataTable? If so, you have to 1st get the item and value from listBox item and add it some other place (in your case to listBox2): [CODE] for(int i = 0; i < listBox1.SelectedItems.Count; i++) { DataRowView view = listBox1.SelectedItem as … | |
Re: Yes it it, or even better it to use: [CODE]this.Dispose();[/CODE] The basic difference between Close() and Dispose() is, when a Close() method is called, any managed resource can be temporarily closed and can be opened once again. It means that, with the same object the resource can be reopened or … | |
Re: I would go to use >= and <= operators to define the start end end date accordingly: [CODE]Dim query As String = "Select * from AFINITY where Description = @description and Datetgl >= @startDate and Datetgl <= endDate"[/CODE] | |
Re: You do: [CODE] //form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(textBox1.Text); f2.Show(); } } //form2: public partial class Form2 : Form { public Form2(string value) { InitializeComponent(); textBox1.Text = value; } } [/CODE] | |
Re: Hi, check [URL="http://www.codeproject.com/KB/aspnet/ImageInDatabase.aspx"]here[/URL]. Remember you have to get Byte array (byte[]) from picture to save it into a dataBase. |