Search Results

Search found 3559 results on 143 pages for 'winforms interop'.

Page 20/143 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Winforms: Attempted to read or write protected memory. This is often an indication that other memory is corrupt

    - by mamcx
    I have a bunch of background events. All of them call a log: private void log(string text, params object[] values) { if (editLog.InvokeRequired) { editLog.BeginInvoke( (MethodInvoker)delegate { this.log(text, values); }); } else { text = string.Format(text, values) + Environment.NewLine; lock (editLog) { editLog.AppendText(text); editLog.SelectionStart = editLog.TextLength; editLog.ScrollToCaret(); } } } Sometimes I get this, but other times not: System.AccessViolationException was unhandled Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.NativeWindow.DefWndProc(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Object& editOle) at System.Windows.Forms.TextBoxBase.ScrollToCaret() at Program1.frmMain.log(String text, Object[] values) in ... ... ... P.D: Not always stop at this line, randomly will be one of the three times editLog methods/properties are used. Not always a exception is throw. Sometimes look like the thing freeze. But not the main UI, just the flow of messages (ie: log look like is never called again) The app is a single form, with background process. I can't see what I doing wrong with this...

    Read the article

  • For a .NET winforms datagridview I would like a combobox column to have a different set of values for each row.

    - by Seth Spearman
    Hello, I have a DataGridView that I am binding to a POCO. I have the databinding working fine. However, I have added a combobox column that I want to be different for each row. Specifically, I have a grid of purchased items, some of which have sizes (like Adult XL, Adult L) and other items are not sized (like Car Magnet.) So essentially what I want to change is the DATA SOURCE for a combobox column in the data grid. Can that be done? What event can I hook into that would allow me to change properties of certain columns FOR EACH ROW? An acceptable alternative is to change a property when the user clicks or tabs into the row. What event is that? Seth EDIT I need more help with this question. With Triduses help I am SO close but I need a bit more information. First, per the question, is the CellFormatting event really the best/only event for changing the DataSource for a combo box column. I ask because I am doing something rather resource/data intensive, not merely formatting the cell. Second, the cellformatting event is being called just by having the mouse hover over the cell. I tried to set the FormattingApplied property inside my if-block and then I check for it in the if- test but that is returning a weird error message. My ideal situation is that I would apply change the data source for the combo box once for each row and then be done with it. Finally, in order to set the data source of the combobox colunm I have to be able to cast the Cell inside my if block to a type of DataGridViewComboBoxColumn so that I can fill it with rows or set the datasource or something. Here is the code I have right now. Private Sub ProductsDataGrid_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles ProductsDataGrid.CellFormatting If e.ColumnIndex = ProductsDataGrid.Columns("SizeDGColumn").Index Then ' AndAlso Not e.FormattingApplied Then Dim product As LeagueOrderProductInfo = DirectCast(ProductsDataGrid.Rows(e.RowIndex).DataBoundItem, LeagueOrderProductInfo) Dim sizes As LeagueOrderProductSizeList = product.ProductSizes sizes.RemoveSizeFromList(_parentOrderDetail.SizeID) 'WHAT DO I DO HERE TO FILL THE COMBOBOX COLUMN WITH THE sizes collection. End If End Sub Please help. I am completely stuck and this task item should have taken an hour and I am 4+ hours in now. BTW, I am also open to resolving this by taking a completely different direction with it (as long as I can be done quickly.) Seth

    Read the article

  • C#, WinForms: Why aren't KeyDown events chaining up to Form? I have to add event handler to each chi

    - by blak3r
    As i understand it, when a button is pressed it should first invoke the Control which has focus' KeyDown Handler, then it call the KeyDown handler for any Parent controls, all the way up to the main form. The only thing that would stop the chain would be if somewhere along the chain one of the EventHandlers did: e.SuppressKeyPress = true; e.Handled = true; In my case, KeyDown events never get to the main form. I have Form - Panel - button for example. Panel doesn't offer a KeyDown Event, but it shouldn't stop it from reaching the main form right? Right now as a work around I set every single control to call an event handler I wrote. I'm basically trying to prevent Alt-F4 from closing the application and instead minimize it.

    Read the article

  • How to show only border of winforms window when resizing?

    - by MartyIX
    I would like to disable displaying of the content of the window when resizing, is it possible? The problem is that when I'm resizing my window the controls redraw on correct positions but it doesn't look good because it's not done fluently. EDIT: I would like a code that would manage the following scenario: I click on the corner of window Now only the border of window is visible - the middle part is transparent I set the size of the window by mouse I release the mouse button and the middle part of the window will appear

    Read the article

  • Why do .NET winforms scale improperly at large DPI settings?

    - by Alex
    My .NET application (VB.NET 3.5 if you really must know) forms do not properly format when rendered at high DPI settings. All of the fixes I've found so far simply explain the cause of the problem as "certain UI elements do not scale properly". I was wondering if anyone had a more meaningful explanation? Thanks!

    Read the article

  • how can I add a custom non-DataTable column to my DataView, in a winforms ADO.net application?

    - by Greg
    Hi, How could I (/is it possible) to add a custom column to my DataView, and in this column display the result of a specific calculation. That is, I currently have a dataGridView which has a binding to a DataView, based on the DataTable from my database. I'd like to add an additional column to the dataGridView to display a number which is calculated by looking at this current row plus it's children row. In other words the info for the column isn't just derivable from the row data itself. Specific questions might be: a) where to add the column itself? to the DataView I assume? b) which method / event to trigger the re-calculation of the value of this custom column from ( / how do I control this) Thanks PS. I've also noted if I use the following code/approach I get a infinite loop... // Custom Items DataColumn dc = new DataColumn("OverallSize", typeof(long)); DT_Webfiles.Columns.Add(dc); DT_Webfiles.RowChanged += new DataRowChangeEventHandler(DT_Row_Changed); private static void DT_Row_Changed(object sender, DataRowChangeEventArgs e) { e.Row["OverallSize"] = e.Row["OverallSize"] ?? 0; e.Row["OverallSize"] = (long)e.Row["OverallSize"] + 1; } What other approach could avoid this looping. i.e. currently I'm saying update the value of the custom column when the row changes, however after then changing the row it triggers antoher 'row has changed' event...

    Read the article

  • graphics don't draw when loop condition is dates. c#, winForms

    - by jello
    so i got this piece of code. (currPosX is defined earlier) while (earliestDate < DateTime.Today) { currPosX = currPosX + 5; e.Graphics.DrawLine(Pens.Black, currPosX, 0, currPosX, 10); earliestDate = earliestDate.AddDays(1); } the graphics don't draw. it's really weird, since this only happens when the condition statement is a date comparison. I debugged, and it does go in the loop, and the values are messed with (currPosX for example). But, no display. one more weirdness, if I add a MessageBox.Show("blabla") in the loop, the message box pops up, and graphics are drawn. what's going on here?

    Read the article

  • C# and Winforms TextBox control: How do I get the text change?

    - by Billy ONeal
    I have an event handler for the TextBox.TextChanged event on a form of mine. In order to support undo, I'd like to figure out exactly what has changed in the TextBox, so that I can undo the change if the user asks for it. (I know the builtin textbox supports undo, but I'd like to have a single undo stack for the whole application) Is there a reasonable way to do that? If not, is there a better way of supporting such an undo feature?

    Read the article

  • How to intercept capture TAB key in WinForms application?

    - by Axarydax
    Hi, could you please help me with this one? I'm trying to capture Tab key in Windows Forms application and do a custom action on it. I have a Form with several listViews and buttons, I've set Form's KeyPreview property to true and when I press any other key than tab, my KeyDown event handler does get called. But that's not true with the Tab key - I don't receive WM_KEYDOWN message even in WndProc. Do I need to set each control inside my form - its TabStop property - to false? There must be a more ellegant way that that. Thanks.

    Read the article

  • How to show only border of window (winforms) when resizing in C#?

    - by MartyIX
    Hi, I would like to disable displaying of the content of the window when resizing, is it possible? The problem is that when I'm resizing my window the controls redraw on correct positions but it doesn't look good because it's not done fluently. EDIT: I would like a code that would manage the following scenario: 1) I click on the corner of window 2) Now only the border of window is visible - the middle part is transparent 3) I set the size of the window by mouse 4) I release the mouse button and the middle part of the window will appear Thank you for help!

    Read the article

  • .NET WinForms INotifyPropertyChanged updates all bindings when one is changed. Better way?

    - by Dave Welling
    In a windows forms application, a property change that triggers INotifyPropertyChanged, will result in the form reading EVERY property from my bound object, not just the property changed. (See example code below) This seems absurdly wasteful since the interface requires the name of the changing property. It is causing a lot of clocking in my app because some of the property getters require calculations to be performed. I'll likely need to implement some sort of logic in my getters to discard the unnecessary reads if there is no better way to do this. Am I missing something? Is there a better way? Don't say to use a different presentation technology please -- I am doing this on Windows Mobile (although the behavior happens on the full framework as well). Here's some toy code to demonstrate the problem. Clicking the button will result in BOTH textboxes being populated even though one property has changed. using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Example { public class ExView : Form { private Presenter _presenter = new Presenter(); public ExView() { this.MinimizeBox = false; TextBox txt1 = new TextBox(); txt1.Parent = this; txt1.Location = new Point(1, 1); txt1.Width = this.ClientSize.Width - 10; txt1.DataBindings.Add("Text", _presenter, "SomeText1"); TextBox txt2 = new TextBox(); txt2.Parent = this; txt2.Location = new Point(1, 40); txt2.Width = this.ClientSize.Width - 10; txt2.DataBindings.Add("Text", _presenter, "SomeText2"); Button but = new Button(); but.Parent = this; but.Location = new Point(1, 80); but.Click +=new EventHandler(but_Click); } void but_Click(object sender, EventArgs e) { _presenter.SomeText1 = "some text 1"; } } public class Presenter : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private string _SomeText1 = string.Empty; public string SomeText1 { get { return _SomeText1; } set { _SomeText1 = value; _SomeText2 = value; // <-- To demonstrate that both properties are read OnPropertyChanged("SomeText1"); } } private string _SomeText2 = string.Empty; public string SomeText2 { get { return _SomeText2; } set { _SomeText2 = value; OnPropertyChanged("SomeText2"); } } private void OnPropertyChanged(string PropertyName) { PropertyChangedEventHandler temp = PropertyChanged; if (temp != null) { temp(this, new PropertyChangedEventArgs(PropertyName)); } } } }

    Read the article

  • C#, WinForms: Which view type for periodically updated list?

    - by rdoubleui
    I'm having an application, that periodically polls a web service (about every 10 seconds). In my application logic I'm having a List<Message> holding the messages. All messages have an id, and might be received out of order. Therefore the class implements the Comparable Interface. What WinForm control would fit to be regurarly updated (with the items in order). I plan to hold the last 500 messages. Should I sort the list and then update the whole form? Or is data binding approriate (concerning performance)?

    Read the article

  • Tool to generate a GUI (WinForms or WPF) from a class.

    - by Pat
    Say we've got a class like public class Doer { public int Timeout {get;set;} public string DoIt(string input) { string toReturn; // Do something that involves a Timeout return toReturn; } } Is there a tool that would create a Form or Control for prototyping this class? The GUI might have a NumericUpDown control with a label of "Timeout" and a GroupBox with a TextBox for "input" and a button labeled "DoIt" with an eventhandler that calls Doer.DoIt with the Text property of the input TextBox and puts the response in another TextBox.

    Read the article

  • WinForms: Why do I get InvalidCastException when showing folder browser dialog?

    - by Marek
    I am randomly getting InvalidCastException when showing FolderBrowserDialog and also many clients have reported this. I have not been able to find anything relevant on the internet. Does anyone know what causes this/how to fix this? My code: using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { fbd.ShowNewFolderButton = false; if (fbd.ShowDialog() == DialogResult.OK) Stack trace: Error: System.InvalidCastException: 'Unable to cast object of type 'System.__ComObject' to type 'IMalloc'.'. Stack trace: at System.Windows.Forms.UnsafeNativeMethods.Shell32.SHGetMalloc(IMalloc[] ppMalloc) at System.Windows.Forms.FolderBrowserDialog.GetSHMalloc() at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner) at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner) at System.Windows.Forms.CommonDialog.ShowDialog() EDIT: Additional information: I have been able to reproduce this only when running in VS2008 debugger. When running out of debugger, it happens only very rarely (happened once or twice in 6 months) on my 64 bit Windows 7 and goes away after restart. The clients are certainly not running the app in debugger so it is surely reproducible out of debugger.

    Read the article

  • Unlock a file with unlocker from a WinForms App?

    - by netadictos
    I am trying to unlock a file from a C# program, using unlocker. In my UI, I put a button to unlock the file the app couldn't delete. When the user pushes the button, I want unlocker (the famous app) to be opened. I have read about in the Unlocker web, and there is some explanations about the commandline to use but nothing works. I write the following code but nothing happens: "c:\Program Files\unlocker\unlocker.exe" -L "PATHFORTHEFILE.doc" Nothing happens. I have tried without parameters and with -LU. Any idea? Something more efficient than unlocker to integrate it with software?

    Read the article

  • Using the using statement with WinForms... Good Practice?

    - by Nate Heinrich
    I understand the concept and reasons behind using the using statement, and I use it with things like file resources and remote connections, I was wondering if it is good practice to use the using statement with WinForm forms and dialogs? using (MyDialog dlg = new MyDialog()) { if (dlg.ShowDialog() == EDialogResult.OK) { // Do Something } } Thanks!

    Read the article

  • How to Get a Specific Column Value from a DataTable? - C#.NET Winforms

    - by peace
    I have a datatable. I need to fetch a certain column value based on the user input. For example, lets say the datatable has two columns CountryID and CountryName. I need to find CountryID in the datatable based on the user input country name. I could just open a connection with DB and run the query select countryID from Country where countryName = @userinput. Is there anyway i could do this on the datatable. Thanks

    Read the article

  • How do I draw a gradated boarder on a polygon using GDI+ via C#/WinForms?

    - by AndyJ
    Hi, I have polygons of various shapes and sizes. They have a solid fill and currently a solid border. I would like to give the polygons a gradient on their edge to soften them. So far I've tried using a Pen with a LinearGradientBrush and whilst the effect it produces is very interesting it's most defintly not what I want ;) I've looked through the System.Drawing.Drawing2D namespace but there didnt seem to be any other classes that would be applicable for this purpose. I've had a search around and the articles that i can find are mostly about creating boarders for rectangles, which are mush easier, or are irrelivent. So to summerise, does anyone have a way of drawing a gradient boarder on a polygon using GDI+?

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >