Search Results

Search found 2806 results on 113 pages for 'winforms'.

Page 62/113 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • How to find out where a thread lock happend?

    - by SchlaWiener
    One of our company's Windows Forms application had a strange problem for several month. The app worked very reliable for most of our customers but on some PC's (mostly with a wireless lan connection) the app sometimes just didn't respond anymore. (You click on the UI and windows ask you to wait or kill the app). I wasn't able to track down the problem for a long time but now I figured out what happend. The app had this line of code // don't blame me for this. Wasn't my code :D Control.CheckForIllegalCrossThreadCalls = false and used some background threads to modify the controls. No I found a way to reproduce the application stopping responding bug on my dev machine and tracked it down to a line where I actually used Invoke() to run a task in the main thread. Me.Invoke(MyDelegate, arg1, arg2) Obviously there was a thread lock somewhere. After removing the Control.CheckForIllegalCrossThreadCalls = false statement and refactoring the whole programm to use Invoke() if modifying a control from a background thread, the problem is (hopefully) gone. However, I am wondering if there is a way to find such bugs without debugging every line of code (Even if I break into debugger after the app stops responding I can't tell what happend last, because the IDE didn't jump to the Invoke() statement) In other words: If my apps hangs how can I figure out which line of code has been executed last? Maybe even on the customers PC. I know VS2010 offers some backwards debugging feature, maybe that would be a solution, but currently I am using VS2008.

    Read the article

  • Sizing issues while adding a .Net UserControl to a TabPage

    - by TJ_Fischer
    I have a complex Windows Forms GUI program that has a lot of automated control generation and manipulation. One thing that I need to be able to do is add a custom UserControl to a newly instatiated TabPage. However, when my code does this I get automatic resizing events that cause the formatting to get ugly. Without detailing all of the different Containers that could possibly be involved, the basic issue is this: At a certain point in the code I create a new tab page: TabPage tempTabPage = new TabPage("A New Tab Page"); Then I set it to a certain size that I want it to maintain: tempTabPage.Width = 1008; tempTabPage.Height = 621; Then I add it to a TabControl: tabControl.TabPages.Add(tempTabPage); Then I create a user control that I want to appear in the newly added TabPage: CustomView customView = new CustomView("A new custom control"); Here is where the problem comes in. At this point both the tempTabPage and the customView are the same size with no padding or margin and they are the size I want them to be. I now try to add this new custom UserControl to the tab page like this: tempTabPage.Controls.Add(customView); When making this call the customView and it's children controls get resized to be larger and so parts of the customView are hidden. Can anyone give me any direction on what to look for or what could be causing this kind of issue? Thanks ahead of time.

    Read the article

  • MouseWheel Event Fire

    - by Rahat
    I have a problem on calling my private method on MouseWheel event. In fact my mouse wheel event gets fired properly when i only increment a variable or display something in Title bar etc. But when i want to call a private method, that method gets called only one time which is not the requirement i want to call that method depending on the speed of scroll i.e. when scroll is done one time slowly call the private method one time but when the scroll is done in high speed call the private method more than one time depending on the scroll speed. For further explanation i am placing the sample code which displays the value of i in Title bar and add it in the Listbox control properly depending on the scroll speed but when i want to call the private method more than one time depending upon the scroll speed, that method gets called only one time. public partial class Form1 : Form { ListBox listBox1 = new ListBox(); int i = 0; public Form1() { InitializeComponent(); // Settnig ListBox control properties this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listBox1.FormattingEnabled = true; this.listBox1.Location = new System.Drawing.Point(13, 13); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(259, 264); this.listBox1.TabIndex = 0; // Attaching Mouse Wheel Event this.listBox1.MouseWheel += new MouseEventHandler(Form1_MouseWheel); // Adding Control this.Controls.Add(this.listBox1); } void Form1_MouseWheel(object sender, MouseEventArgs e) { i++; this.Text = i.ToString(); this.listBox1.Items.Add(i.ToString()); // Uncomment the following line to call the private method // this method gets called only one time irrelevant of the // mouse wheel scroll speed. // this.LaunchThisEvent(); } private void Form1_Load(object sender, EventArgs e) { this.listBox1.Select(); } private void LaunchThisEvent() { // Display message each time // this method gets called. MessageBox.Show(i.ToString()); } } How to call the private method more than one time depending upon the speed of the mouse wheel scroll?

    Read the article

  • Uncertain response from Combobox SelectedItem

    - by MSingh
    I am working in winform and using combobox. I set the properties of combobox in this sequence combobox.DisplayMember = "cust_name"; combobox.ValueMember="cust_id"; combobox.datasource=dtCustomer; I have used combobox in my application several times, I don't know where I am making mistake as Sometime SelectedItem property returns exact value (int,string) based on the data type of "ValueMember" property, but sometime it returns "DataRowView". I've read this is because of the sequence in which properties are setting in combobox. But this is not the case now. Binding code is Calling code is

    Read the article

  • save the input value in a 2dimentsion array

    - by arash
    hi friends,how can i save the number that user enter in textbox in a 2 dimension array? for example: i have this numbers in textbox:45,78 and now i want to save 45,32 like this: array[0,0]=45 and array[0,1]=78 how can i do that?thanks,so much edited: oh,when i entered 1,2,3,4,5,6,7,8,9 in textbox and it takes [2,2]=56 private void button10_Click(object sender, EventArgs e) { int matrixDimention = 2; int[,] intValues = new int[matrixDimention + 1, matrixDimention + 1]; string[] splitValues = textBox9.Text.Split(','); for (int i = 0; i < splitValues.Length; i++) intValues[i % (matrixDimention + 1), i % (matrixDimention + 1)] = Convert.ToInt32(splitValues[i]); string a=intValues[2,2].ToString(); MessageBox.Show(a); } when i take: string a=intValues[2,1].ToString(); it shows 0

    Read the article

  • When using DrawText, what does TextFormatFlags.Internal (a.k.a. DT_INTERNAL) do?

    - by Daniel Stutzbach
    When using TextRenderer.DrawText(), what does setting the TextFormatFlags.Internal flag actually do? Equivalently, what does setting the DT_INTERNAL flag to Win32's DrawTextEx() function do? More to the point, when should I set that flag and when should I not set it? The documentation says: "Uses the system font to calculate text metrics", but I'm not entirely sure what that means. I've done some limited testing and setting the flag seems to change how the font is rendered when using a small font size, but doesn't seem to make a difference when using a large font size.

    Read the article

  • Binding an Ilist to datagridview containing another object in a field

    - by JaSk
    I have pretty much the same problem as this question http://stackoverflow.com/questions/970741 but in windows forms, can anyone help me solve it? this is my code, so you don't have to check the other question: public class Material { public virtual int id { get; private set; } public virtual string nombre { get; set; } public virtual string unidad { get; set; } public virtual Categorias Categoria { get; set; } public virtual IList Materiales { get; set; } public Material() { Materiales = new List<Materiales>(); } public virtual void AddMateriales(Materiales materiales) { materiales.Material = this; this.Materiales.Add(materiales); } } as you can see I have an object within the IList so when I use the List as the data source for a datagridview I get a object.categoria where I want to get the Categoria.Name property, can anyone help me?. Thanks

    Read the article

  • Determite when and which a character added or deleted to/from a Text Box.

    - by Alon
    I have a simple text box in a WPF application. I need to know when a character was added/deleted in the text box, which character and where it was added or deleted. I thought to use the TextBox.KeyDown event, but it has some problems: I can't know where the character was added or deleted. I have no idea how to determite which character was added (from the KeyEventArgs). Any ideas? I don't care to use a completely different solution from what I thought. In addition, I've just started this project so I don't care to use Windows Forms instead of WPF if your solution requires it. Thank you.

    Read the article

  • Displaying Data on the Form with C#

    - by The.Anti.9
    I'm searching files and returning lines that include the search text, and I'm not really sure the best way to display the information I get. Every time I get a match, I want to show, in some sort of control, the File it came from, and the whole text line. (aka streamreader.ReadLine() result). First I tried just putting it all in a read-only text box, but it doesn't have a scroll bar. What is the best form control to help me display this data neatly?

    Read the article

  • How to Select Multiple Records from Multiple Tables at Once - SQL Server/C#/.NET/T-SQL

    - by peace
    I have two tables Customer and CustomerPhone. Customer usually has multiple phone numbers, so when i run select statement on customer 101, i will get multiple records due to the multiple phone numbers. As you see below all the "Phone" and "Fax" field belongs to CustomerPhone table. These are considered as two records in the CustomerPhone table whereas the rest of fields relate to Customer table which is a single record. What should i do to fill Phone and Fax field in this case? Should i run select statement on CustomerPhone first and then run select statement on Customer?

    Read the article

  • What Windows message is fired for mouse-up with modifier keys?

    - by Greg
    My WndProc isn't seeing mouse-up notifications when I click with a modifier key (shift or control) pressed. I see them without the modifier key, and I see mouse-down notifications with the modifier keys. I'm using the Windows Forms NativeWindow wrapper to get Windows messages from the WndProc() method. I've tried tracking the notifications I do get, and I the only clue I see is WM_CAPTURECHANGED. I've tried calling SetCapture when I receive the WM_LBUTTONDOWN message, but it doesn't help. Without modifier (skipping paint, timer and NCHITTEST messages): WM_LBUTTONDOWN WM_SETCURSOR WM_MOUSEMOVE WM_SETCURSOR WM_LBUTTONUP With modifier (skipping paint, timer and NCHITTEST messages): WM_KEYDOWN WM_PARENTNOTIFY WM_MOUSEACTIVATE WM_MOUSEACTIVATE WM_SETCURSOR WM_LBUTTONDOWN WM_SETCURSOR (repeats) WM_KEYDOWN (repeats) WM_KEYUP If I hold the mouse button down for a long time, I can usually get a WM_LBUTTONUP notification, but it should be possible to make it more responsive.. What am I missing? Thanks.

    Read the article

  • Monitor Screen Independent Forms size & Control Size?

    - by Thomas
    in various case i have seen that when we run apps in various pc with different monitor size then win form behave differently. sometime the form get bigger and as a result few control on that form will not visible.so please tell me how to design win apps in such a way that what ever the monitor size would be the form size and control position will behave same way in all the pc monitor size.please guide me.thanks.

    Read the article

  • SharpGL: Can't draw all lines from List

    - by Miko Kronn
    I have: float[,] nodesN = null; //indexes: //number of node; //value index 0->x, 1->y, 2->temperature int[,] elements = null; //indexes: //indexof element (triangle) //1, 2, 3 - vertexes (from nodesN) List<Pair> edges = null; //Pair is a class containing two int values which are //indexes of nodesN And function which is supposed do all elements and edges on SharpGL.OpenGLCtrl private void openGLCtrl1_Load(object sender, EventArgs e) { gl = this.glCtrl.OpenGL; gl.ClearColor(this.BackColor.R / 255.0f, this.BackColor.G / 255.0f, this.BackColor.B / 255.0f, 1.0f); gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT); } float glMinX = -2f; float glMaxX = 2f; float glMinY = -2f; float glMaxY = 2f; private void openGLControl1_OpenGLDraw(object sender, PaintEventArgs e) { gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -6.0f); if (!draw) return; bool drawElements = false; if (drawElements) { gl.Begin(OpenGL.TRIANGLES); for (int i = 0; i < elementNo; i++) { for (int j = 0; j < 3; j++) { float x, y, t; x = nodesN[elements[i, j], 0]; y = nodesN[elements[i, j], 1]; t = nodesN[elements[i, j], 2]; gl.Color(t, 0.0f, 1.0f - t); gl.Vertex(x, y, 0.0f); } } gl.End(); } gl.Color(0f, 0f, 0f); gl.Begin(OpenGL.LINES); //for(int i=edges.Count-1; i>=0; i--) for(int i=0; i<edges.Count; i++) { float x1, y1, x2, y2; x1 = nodesN[edges[i].First, 0]; y1 = nodesN[edges[i].First, 1]; x2 = nodesN[edges[i].Second, 0]; y2 = nodesN[edges[i].Second, 1]; gl.Vertex(x1, y1, 0.0f); gl.Vertex(x2, y2, 0.0f); } gl.End(); } But it doesn't draw all the edges. If i change drawElements it draws different number of edges. Changing for(int i=0; i<edges.Count; i++) to for(int i=edges.Count-1; i>=0; i--) shows that esges are generated correctly, but they are not drawn. Images: for(int i=0; i<edges.Count; i++) drawElements=false for(int i=edges.Count-1; i>=0; i--) drawElements=false for(int i=0; i<edges.Count; i++) drawElements=true for(int i=edges.Count-1; i>=0; i--) drawElements=true What is wrong with this? How can I draw all edges?

    Read the article

  • Does not contain a definition

    - by JB
    public void button2_Click(object sender, System.EventArgs e) { string text = textBox1.Text; Mainform = this; this.Hide(); GetSchedule myScheduleFinder = new GetSchedule(); string result = myScheduleFinder.GetDataFromNumber(text);// says there is no definition if (!string.IsNullOrEmpty(result)) { MessageBox.Show(result); } else { MessageBox.Show("Enter A Valid ID Number!"); } } says it does not contain definition for it but on my GetSchedule .cs file i have it defined public string GetDataFromNumber(string ID)//defined here { foreach (IDnumber IDCandidateMatch in IDnumbers) { if (IDCandidateMatch.ID == ID) { StringBuilder myData = new StringBuilder(); myData.AppendLine(IDCandidateMatch.Name); myData.AppendLine(": "); myData.AppendLine(IDCandidateMatch.ID); myData.AppendLine(IDCandidateMatch.year); myData.AppendLine(IDCandidateMatch.class1); myData.AppendLine(IDCandidateMatch.class2); myData.AppendLine(IDCandidateMatch.class3); myData.AppendLine(IDCandidateMatch.class4); //return myData; return myData.ToString(); } } return ""; } } } }

    Read the article

  • DataGridView with row-specific DataGridViewComboBoxColumn contents

    - by XXXXX
    So I have something like the following data structure (constructors omitted) class Child { public string Name { get; set; } public int Age { get; set; } } class Parent { public string Name { get; set; } public List <Child> Children { get; private set; } // never null; list never empty public Child FavoriteChild { get; set; } // never null; always a reference to a Child in Children } List < Parent > Parents; What I want to do is show a DataGridView where each row is a Parent from Parent list. Each row should have two columns: a text box showing the parent's name and a DataGridViewComboBoxColumn containing that parent's children, from which the user can select the parent's favorite child. I suppose I could do the whole thing manually, but I'd like to do all this with more-or-less standard Data Binding. It's easy enough to bind the DataGridView to the list of parents, and easy enough to bind the selected child to the FavoriteChild property. The part that's giving me difficulty is that it looks like the Combo Box column wants to bind to one data source for all the combo-box's contents on all rows. I'd like each instance of the combo box to bind to the list of each parent's children. I'm fairly new to C#/Windows Forms, so I may well be missing something obvious. Or it could be that "you can't get there from here." It's not too tough to make a separate list of all the children and filter it by parent; I'm looking into that possibility right now. Is this feasible, or is there a better way?

    Read the article

  • What makes a Winform position initially stale?

    - by msorens
    The code below demonstrates a very simple problem; I am hoping that I am just missing a setting that someone might be able to reveal. Goal (1) Launch main winform (MainForm). (2) Press button to display secondary winform (ShadowForm) that is semi-transparent and should exactly overlay MainForm. What Actually Happens Scenario 1: Launch main winform then press button: ShadowForm displays with correct size but incorrect location, lower and to the right (as if it was cascaded). Press button to close ShadowForm again. Press button once more to reopen ShadowForm and now it is in the correct position, covering MainForm. Scenario 2: Launch main winform, move it around, then press button: ShadowForm displays with correct size but incorrect location (where the MainForm was before moving it). Press button to close; press again to reopen and now ShadowForm is in the correct position. using System; using System.Windows.Forms; namespace LocationTest { static class Program { static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } } public class MainForm : Form { ShadowForm shadowForm = new ShadowForm(); Button button1 = new Button(); System.ComponentModel.IContainer components = null; public MainForm() { this.SuspendLayout(); this.button1.Location = new System.Drawing.Point(102, 44); this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.button1); this.ResumeLayout(false); } private void button1_Click(object sender, EventArgs e) { if (shadowForm.Visible) { shadowForm.Hide(); } else { shadowForm.Size = Size; // this always works shadowForm.Location = Location; // this fails first time, but works second time! shadowForm.Show(); } } protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } } public class ShadowForm : Form { private System.ComponentModel.IContainer components = null; public ShadowForm() { this.SuspendLayout(); this.BackColor = System.Drawing.Color.Black; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Opacity = 0.5; this.Click += new System.EventHandler(this.ShadowForm_Click); this.ResumeLayout(false); } private void ShadowForm_Click(object sender, EventArgs e) { Hide(); } protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } } }

    Read the article

  • C# app running as either Windows Form or as Console Application

    - by Aeolien
    I am looking to have one of my Windows Forms applications be run programmatically—from the command line. In preparation, I have separated the logic in its own class from the Form. Now I am stuck trying to get the application to switch back and forth based on the presence of command line arguments. Here is the code for the main class: static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) // gets passed its path, by default { CommandLineWork(args); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } private static void CommandLineWork(string[] args) { Console.WriteLine("It works!"); Console.ReadLine(); } where Form1 is my form and the It works! string is just a placeholder for the actual logic. Right now, when running this from within Visual Studio (with command line arguments), the phrase It works! is printed to the Output. However, when running the /bin/Debug/Program.exe file (or /Release for that matter) the application crashes. Am I going about this the right way? Would it make more sense (i.e. take less developer time) to have my logic class be a DLL that gets loaded by two separate applications? Or is there something entirely different that I'm not aware of? Thanks in advance!

    Read the article

  • Visual Studio Unit Testing of Windows Forms

    - by GWLlosa
    We're working on a project here in Visual Studio 2008. We're using the built-in testing suite provided with it (the Microsoft.VisualStudio.TestTools.UnitTesting namespace). It turns out, that much to our chagrin, a great deal of complexity (and therefore errors) have wound up coded into our UI layer. While our unit tests do a decent job of covering our business layer, our UI layer is a constant source of irritation. We'd ideally like to unit-test that, as well. Does anyone know of a good "Microsoft-compatible" way of doing that in visual studio? Will it introduce some sort of conflict to 'mix' unit testing frameworks like nUnitForms with the Microsoft stuff? Are there any obvious bear traps I should be aware of with unit-testing forms?

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >