Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
Y

Yannielsen

@Yannielsen
About
Posts
11
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Troubles with parsing data from on function to another
    Y Yannielsen

    Hi, I have a class where i'm creating a ButtonArray. Once i have created some elements in this array i want to access each of them in order to move them around in a panel. However i can't seem to get the information from the Move() funtion to be used in the MouseUpHandler which is the one handling the release of a button press (dropping the button at a new location). Could anyone please help me out here, and please do say if you need more code than i have provided. public void MouseUpHandler(object sender, System.Windows.Forms.MouseEventArgs e) { this.Move((System.Windows.Forms.Button) sender).Tag), host, _iXCoorRelative, _iYCoorRelative); } public void Move(object sender, System.Windows.Forms.Control host, int _iXCoorRelative, int _iYCoorRelative) { ButtonArray btnArray = new ButtonArray(host); btnArray[Convert.ToInt32(((System.Windows.Forms.Button) sender).Tag)].Location = new System.Drawing.Point (_iXCoorRelative, _iYCoorRelative); }

    C# graphics data-structures json help announcement

  • Problem with this function..
    Y Yannielsen

    The tempArray and ButtonArray comes from here in the main form ButtonArray btnArray; ButtonArray tempArray; <...> private void Form1_Load(object sender, System.EventArgs e) { btnArray = new ButtonArray(this); tempArray = new ButtonArray(this); } Both ButtonArrays come from this class using System; namespace ButtonArray { /// /// Summary description for ButtonArray. /// public class ButtonArray : System.Collections.CollectionBase { private readonly System.Windows.Forms.Form HostForm; public System.Windows.Forms.Button AddNewButton() { // Create a new instance of the Button class. System.Windows.Forms.Button aButton = new System.Windows.Forms.Button(); // Add the button to the collection's internal list. this.List.Add(aButton); // Add the button to the controls collection of the form // referenced by the HostForm field. HostForm.Controls.Add(aButton); // Set intial properties for the button object. aButton.Top = Count * 25; aButton.Left = 100; aButton.Tag = this.Count; aButton.Text = "Button " + this.Count.ToString(); aButton.Click += new System.EventHandler(ClickHandler); return aButton; } public ButtonArray(System.Windows.Forms.Form host) { HostForm = host; this.AddNewButton(); } public System.Windows.Forms.Button this [int Index] { get { return (System.Windows.Forms.Button) this.List[Index]; } set { this.List[Index] = value; } } public void RemoveX(int iRemoveX) { // Check to be sure there is a button to remove. if (this.Count > 0) { // Remove the button indexed with the value of iRemoveX HostForm.Controls.Remove(this[iRemoveX-1]); this.List.RemoveAt(this.Count-1); } } public void RemoveButton() { // Check to be sure there is a button to remove. if (this.Count > 0) { // Remove the last button added to the array from the host form // controls collection. Note the use of the indexer in accessing // the array. HostForm.Controls.Remove(this[this.Count -1]); this.List.RemoveAt(this.Count -1); } } public void FlushArray() { // Check to be sure there is a button to remove. if (this.Count > 0) { for(int iButtonIndex = this.Count; iButtonIndex > 0; iButtonIndex--) { // Remove the button indexed with the value of iRemoveX HostForm.Controls.Re

    C# help css database data-structures

  • Problem with this function..
    Y Yannielsen

    I'm doing this piece of code which should copy the non-null elements in btnArray to the tempArray. Afterwards it should copy the elements of tempArray back to btnArray in order to get rid of the null elements and restructure the array. However i'm getting the following exception: "Specified argument was out of the range of valid values." "Parameter name: Index was out of range. Must be non-negative and less than the size of the collection." I can ofcourse interpret this, but i can't see where i'm making the mistake, i even tried doing the calculations manually and they seem to fit.. or else i'm doing something wrong :confused: If anyone could point out the mistake i'm making i'd be very thankful :) private void CopyArray() { try { if(btnArray.Count > 0) { int iCounter = 0; for (int iButtonIndex = btnArray.Count; iButtonIndex > 0; iButtonIndex--) { if (btnArray[iButtonIndex-1] != null) { tempArray[iCounter] = btnArray[iButtonIndex-1]; iCounter++; } } for (int iButtonIndex = 0; iButtonIndex < tempArray.Count; iButtonIndex++) { btnArray[iButtonIndex] = tempArray[iButtonIndex]; } } else { MessageBox.Show("(COPY) ARRAY IS EMPTY"); } } catch(Exception ex) { MessageBox.Show("ERROR: " + ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1); } }

    C# help css database data-structures

  • Problems with Array being readonly (HELP)
    Y Yannielsen

    Thanks alot for the help!

    C# help graphics docker data-structures question

  • Problems with Array being readonly (HELP)
    Y Yannielsen

    I see.. would you happen to have a suggestion on how to make this set method? :) Thanks alot for the help so far

    C# help graphics docker data-structures question

  • Problems with Array being readonly (HELP)
    Y Yannielsen

    // Declare a new ButtonArray object. ButtonArray btnArray; ButtonArray tempArray; btnArray = new ButtonArray(this); tempArray = new ButtonArray(this); private void CopyArray() { try { if(btnArray.Count > 0) { int iCounter; for (int iButtonIndex = 0; iButtonIndex < btnArray.Count; iButtonIndex++) { if (btnArray[iButtonIndex] != null) { tempArray[iCounter++] = btnArray[iButtonIndex]; iCounter++; } } } else { MessageBox.Show("(COPY) ARRAY IS EMPTY"); } } catch(Exception ex) { MessageBox.Show("ERROR: " + ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1); } } ---------------------------------------------------------------- CODE FOR BUTTONARRAY.CS BELOW ---------------------------------------------------------------- using System; namespace ButtonArray { public class ButtonArray : System.Collections.CollectionBase { private readonly System.Windows.Forms.Form HostForm; public System.Windows.Forms.Button AddNewButton() { // Create a new instance of the Button class. System.Windows.Forms.Button aButton = new System.Windows.Forms.Button(); // Add the button to the collection's internal list. this.List.Add(aButton); // Add the button to the controls collection of the form // referenced by the HostForm field. HostForm.Controls.Add(aButton); // Set intial properties for the button object. aButton.Top = Count * 25; aButton.Left = 100; aButton.Tag = this.Count; aButton.Text = "Button " + this.Count.ToString(); aButton.Click += new System.EventHandler(ClickHandler); return aButton; } public ButtonArray(System.Windows.Forms.Form host) { HostForm = host; this.AddNewButton(); } public System.Windows.Forms.Button this [int Index] { get { return (System.Windows.Forms.Button) this.List[Index]; } } public void Remove(int iRemoveX) { // Check to be sure there is a button to remove. if (this.Count > 0) { // Remove the last button added to the array from the host form // controls collection. Note the use of the indexer in accessing // the array. // Remove the button indexed with the value of iRemoveX HostForm.Controls.Remove(this[iRemoveX]); this.List.RemoveAt(this.Count -1); } } public void ClickHandler(Object sender, System.EventArgs e) { System.Windows.Forms.MessageBox.Show("You have clicked button " + ((System.Windows.Forms.Button) sender).Tag.ToString()); } } }

    C# help graphics docker data-structures question

  • Problems with Array being readonly (HELP)
    Y Yannielsen

    Below i have posted the code for my little project, my problem is located at the line looking like this "tempArray[iCounter++] = btnArray[iButtonIndex];" and i'm getting this error: Property or indexer 'ButtonArray.ButtonArray.this[int]' cannot be assigned to -- it is read only What i'm trying to do is this, once i have removed an object from btnArray, i want to copy the remaining stuff of btnArray to tempArray in order to re-arrange the elements. This should be done through the CopyArray(). However i can't figure out why im getting a readonly error, can anyone please help me out? Thanks alot in advance! ----------------------------------------------------------------- CODE FOR FORM1.CS BELOW ----------------------------------------------------------------- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using ButtonArray; namespace ButtonArray { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button btnAdd; private System.Windows.Forms.Button btnRemove; private System.Windows.Forms.Button btnRemoveX; private System.Windows.Forms.TextBox txtRemoveX; public int iRemoveX; // Declare a new ButtonArray object. ButtonArray btnArray; ButtonArray tempArray; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.btnAdd = new System.Windows.Forms.Button(); this.btnRemove = new System.Windows.Forms.Button(); this.btnRemoveX = new System.Windows.Forms.Button(); this.txtRemoveX = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // //

    C# help graphics docker data-structures question

  • How to collapse an array?
    Y Yannielsen

    Hi there. I'm fiddling around with arrays and i need to collapse (re-arrange) an array. Currently i have no clue how to do it, so if anyone could help out with a little example or some hints i would be thankful. An example of what i want to do: --------------------------------- An array containing 5 elements 1 - 2 - 3 - 4 - 5 If i remove element index 3 from the array i want the index of element 4 to change to 3 and the index of element 5 to chance to 4. How is this possible? Thanks alot in advance!

    C# tutorial database data-structures help question

  • Getting screensize
    Y Yannielsen

    Thanks alot!

    C# help tutorial question

  • Getting screensize
    Y Yannielsen

    Hi! Can anyone help me getting the current screensize the user is using? I have tried several things now but i really have no clue how to get it.. Thanks alot in advance

    C# help tutorial question

  • Need help with threading
    Y Yannielsen

    Hi im new at these forums, so this is my first post, i hope that some of you guys could help me out with this problem i have. I'm building a drag n' drop program that will allow a user to drag n drop an item (like a button) from one control to another. Currently i have a problem managing threads, or rather parsing data between them. My problem is this. I need to sample the mouse's x and y coordinates for each control so that it will drop the item at the correct place in the control. The reason im using threading is that once i start dragging an object (button) the sampling of the x and y coordinates pauses. Thus i need to run it in another thread. My problem is that i can't seem to get _GetLocalMouseCoordinates to run in a thread of its own, i get this error C:\Documents and Settings\My Documents\Visual Studio Projects\DragNDrop\DragDrop.cs(359): Method 'DragNDrop.Form1._GetLocalMouseCoordinates(object, System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Threading.ThreadStart()' The code is below, i have only pasted the "vital" part though. I hope that someone cna help. Thanks alot in advance! using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; namespace DragNDrop { /// /// Summary description for Form1. /// /// Huske/tænke liste /// /// 1. Threading hvor hurtig opdaterings tid kan formen klare uden at choke? /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Panel pnlDrag; private System.Windows.Forms.Panel pnlDrop; private System.Windows.Forms.Label lblDrag; private System.Windows.Forms.Label lblDrop; private System.Windows.Forms.Button btnDrag; private System.Windows.Forms.Button btnPush; private System.Windows.Forms.StatusBar statusBarGlobal; private System.Windows.Forms.StatusBar statusBarLocalDrop; private System.Windows.Forms.StatusBar statusBarLocalDrag; // My generated variables etc. public int iXCoorDrag; public int iYCoorDrag; public int iXCoorDrop; public int iYCoorDrop; public int iXCoorGlobal; public int iYCoorGlobal; public Thread GlobalMouseThread; public Thread LocalMouseThread; public bool bStopthread; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Design

    C# help csharp visual-studio graphics design
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups