User Profile

Collapse

Profile Sidebar

Collapse
Falkeli
Falkeli
Last Activity: May 10 '15, 08:10 PM
Joined: Feb 9 '12
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • I think that what you want is to set these TextBox's HideSelection property to false.
    See more | Go to post

    Leave a comment:


  • How can I rearrange the rows of a DataGridView in the code?

    I have a DataGridView of WinForms, and I want to be able to rearrange the rows using a ListBox located elsewhere. So when I remove an entry from the ListBox, the following line is run:
    Code:
    dataGridView1.Rows.RemoveAt(e.Index);
    And when an element is added to the ListBox, the following code is executed:
    Code:
    dataGridView1.Rows.Insert(e.Index, row);
    Except that an exception (InvalidOperati onException) is thrown since the row is in...
    See more | Go to post

  • Creating a column for a DataGridView without inserting it immediately

    I have a DataGridView object. Elsewhere in the program, I want to create code which does something like this:
    Code:
    DataGridViewColumn col = new DataGridViewColumn();
    listBox1.Items.Add(col);
    And then subsequently add it to the DataGridView later. Unfortunately, when I try this, adding it to the DataGridView throws an exception because "At least one of the DataGridView control's columns has no cell template."...
    See more | Go to post

  • Falkeli
    replied to How to define unlimited array ?
    I think, from your description, that you need a List<double> type.
    See more | Go to post

    Leave a comment:


  • Falkeli
    replied to Bug color drawed rectangle
    It sounds like the rectangle simply isn't being repainted properly - try using the Paint event.
    See more | Go to post

    Leave a comment:


  • Falkeli
    started a topic How do I add items dynamically to a WrapPanel?
    in XAML

    How do I add items dynamically to a WrapPanel?

    I have the following XAML:
    Code:
    <Window x:Class="ImageComparing.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="350" Width="525" xmlns:my="clr-namespace:ImageComparing" Title="Image comparing">
        <DockPanel>
            <ToolBar
    ...
    See more | Go to post

  • Code:
    if (rating>=3.5)
        form.BackColor = System.Drawing.Color.Red;
    If the condition is in a method of the form, replace the word "form" with "this"; if it's elsewhere, use a variable refering to the form.
    See more | Go to post

    Leave a comment:


  • Make sure to add them to the form in the order you wrote the docking:
    Code:
    this.Controls.Add(myBrowser);
    this.Controls.Add(toolStrip);
    I think that should work.
    See more | Go to post

    Leave a comment:


  • By the time the code reaches your condition here, the dialog is already closed. What you need to do is edit the code of the dialog itself - and remove the DialogResult.Ye s result from the "Next" button. Or else you can simpoly re-open the dialog box with an other ShowDialog().
    See more | Go to post

    Leave a comment:


  • Falkeli
    replied to Compare 4 arrays for equality
    In C#, this checks if the array references point to the same object, not if they are equal internally.

    What you can do is use the following function:

    Code:
    bool ArraysEqual<T>(T[] first, T[] second)
    {
        if (first==second)
            return true;
        if (first==null || second==null)
            return false;
        if (first.Length != second.Length)
            return false;
    ...
    See more | Go to post

    Leave a comment:


  • Falkeli
    started a topic Get right click on a ListBox to select item

    Get right click on a ListBox to select item

    I have a ListBox with an associated ContextMenu. I want to ensure that, if the user right-clicks on an item, that the item will be selected and the ContextMenu will open properly for it - similarly to the way it works in Explorer.
    See more | Go to post

  • Using a KeyDown event and a KeyUp event you could check for the user pressing alt (you get a KeyDown when the user presses it, and a KeyUp when he/she stops); use this to exclude alt-F4. The condition you need in the KeyDown and KeyUp events is:
    Code:
    if (e.KeyCode == Keys.Alt)
    You need to set the form's KeyPreview property to true.
    See more | Go to post

    Leave a comment:


  • As far as I know, there is no other way to detect this. Simply make sure to have a flag to be used to detect any other control set to close the form, and then check for e.CloseReason == CloseReason.Use rClosing in the FromClosing event to make sure that the window isn't being closed by the parent or the OS.
    See more | Go to post

    Leave a comment:


  • Falkeli
    replied to string comparison
    in .NET
    To check if str2 is a substring of str1 (that is, str1 contains str2), use the following line:
    Code:
    if (str1.Contains(str2))
        //put code here
    I hope this helps you.
    See more | Go to post

    Leave a comment:


  • Make the checkboxes in a DataGridViewCheckBoxColumn be checked

    I have tried to use the following code when adding a new row:
    Code:
    DataGridViewRow row = new DataGridViewRow();
    dataGridView1.Rows.Add(row);
    row.Cells[0].Value = true;
    //and more initialization
    I have tried replacing the word "true" with 1, after setting the TrueValue property of the column to 1. Neither the code above, nor the change described below, makes the checkboxes be checked. How do I make them...
    See more | Go to post

  • Falkeli
    replied to Deep copying
    To make it clearer:

    Let's assume we have the following class:
    Code:
    class Example
    {
        private int[] numbers;
        private StringBuilder builder;
    
        public Example()
        {
            numbers = new int[20];
            builder=  new StringBuilder();
        }
    
        // And other methods
    }
    Let example1 be an object of type Example;...
    See more | Go to post

    Leave a comment:


  • One of these is a "Category dropdown". It's a ComboBox populated by a list of categories fetched from the disk. In design mode, this file can't be accessed, so an exception is thrown. I currently have this wrapped in a try/catch block with an empty catch, but this means that should there be any exception while running the code in runtime, I'll get an ignored exception which could end up complicating other things.
    See more | Go to post

    Leave a comment:


  • Falkeli
    replied to Unhandled exception
    I'm not sure, but this may be a feature of the debugger, designed to help you debug the program if an unexpcected exception occurs under these circumstances.
    See more | Go to post

    Leave a comment:


  • Prevent the designer from trying to run specific code

    I'm writing a WinForms program, in which I have some user controls. Some of these user controls need to do things before being displayed, which cause the designer not to be able to use these controls. I've tried moving the relevant code from the constructor to the Load event, but it's still crashing the designer. Where should I put this code?
    See more | Go to post
No activity results to display
Show More
Working...