Search Results

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

Page 72/113 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • How can I receive the "scroll box" type scroll events from a DataGridView?

    - by Simon
    I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On the MSDN documentation page it says I should be able to detect movement of the scroll box by listening for events with types ThumbPosition, ThumbTrack, First, Last and EndScroll. However, when I drag the scroll box, I only get events of type LargeDecrement and LargeIncrement. How do I get access to the ThumbPosition, ThumbTrack, First, Last and EndScroll events?

    Read the article

  • How to focus a control in an MDIParent when all child windows have closed?

    - by Tim Gradwell
    I have a control in my parent mdi form which I wish to be given the focus if all mdi children have closed. I've tried hooking into the child form's FormClosed event and setting the focus from there but when I test it, my control is not left with focus when I close the mdi child. Can anyone tell me what I'm missing? In the sample below, "first focus" gets hit and does its job correctly (if I comment out the first focus line, my tree does not get focus on startup, so it must be doing its job, right?) Unfortunately, even though "second focus" gets hit, my tree does not end up with the focus when I close the child window. Sample using System; using System.Windows.Forms; namespace mdiFocus { class ParentForm : Form { public ParentForm() { IsMdiContainer = true; tree = new TreeView(); tree.Nodes.Add("SomeNode"); tree.Dock = DockStyle.Left; Controls.Add(tree); } protected override void OnShown(EventArgs e) { Form child = new Form(); child.MdiParent = this; child.Show(); child.FormClosed += new FormClosedEventHandler(child_FormClosed); tree.Focus(); // first focus works ok } void child_FormClosed(object sender, FormClosedEventArgs e) { tree.Focus(); // second focus doesn't seem to work, even though it is hit :( } TreeView tree; } static class Program { [STAThread] static void Main() { Application.Run(new ParentForm()); } } }

    Read the article

  • Difference between ISupportInitialize (BeginInit/EndInit) and SuspendLayout/ResumeLayout

    - by Pato
    Hello All! Could someone please explain what the difference is between using the ISupportInitialize interface methods (BeginInit/EndInit) and using SuspendLayout/ResumeLayout? Is ISupportInitialize ONLY used during construction/"initial" initialization... or can it be used later when you want to add new child controls to an existing parent control? Any particular differences? I greatly appreciate your help! Thank you, Pato

    Read the article

  • Creating a form on non-gui thread

    - by luntain
    You can't access gui controls from a thread they were not created on, at least so says the message of an exception that is sometimes raised when you do it. Recently I was puzzled by seeing that forms created on background threads work just fine. My mental model was that all actions initiated by UI input is handled on the GUI thread. Clicking on a button on such a form should raise the dreaded exception (the form and all its controls were created on a background thread not the gui thread), but it doesn't. Something is wrong with my map. (*) well to be honest I have seen one problem where opening the standard open file dialog was blocking everything

    Read the article

  • Why is only the first shown window focusable

    - by Miha Markic
    Imagine the code below. Only the first window appears on the top, all of subsequent windows won't nor can they be programatically focused for some reason (they appear in the background). Any idea how to workaround this? BTW, static methods/properties are not allowed nor is any global property. [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread t1 = new Thread(CreateForm); t1.SetApartmentState(ApartmentState.STA); t1.Start(); t1.Join(); t1 = new Thread(CreateForm); t1.SetApartmentState(ApartmentState.STA); t1.Start(); t1.Join(); } private static void CreateForm() { using (Form f = new Form()) { System.Windows.Forms.Timer t = new System.Windows.Forms.Timer { Enabled = true, Interval = 2000 }; t.Tick += (s, e) => { f.Close(); t.Enabled = false; }; f.TopMost = true; Application.Run(f); } }

    Read the article

  • Unauthorisedaccessexception - how to gain access?

    - by cfan
    I have a winform application to compress and move some files. When I try to access a path on my desktop, I get an unauthorisedaccess exception. I am running visual studio as administrator (says that in the program bar) and I am a full admin on my machine (can access other accounts, etc). How can I acess this path (folder)? One of the problems I have is the folder keeps setting itself to readonly. Thanks

    Read the article

  • Format of DataGridView value

    - by Vadim
    I have a DataGridView which is filling from Table in SQL Server Database. One of it's columns is "price". Type of column in DGV is automatically sets as Decimal. In some cases I need to write in cells of this column text like "none", instead of price. How can I do it? DGV.Item("price", 0).Value = "none" doesn't work, because of decimal type of a cell.

    Read the article

  • Interface issue

    - by peter
    i added a property 'WrmVersion' in interface IResourcePolicy but i am not getting those thing in the implementation side means here it should come in the List view data. means SubItems.Add(((IResourcePolicy)Data).WrmVersion is not getting This is the interface public interface IResourcePolicy { DataVersion WrmVersion { get; set; } bool ResourcePolicyEnabled { get; set; } } i am implementing it in public new IResourcePolicy Data { get { return (IResourcePolicy)base.Data; } } protected override void OnUpdate() { if(Data != null) { Text = base.Data.Name; if(SubItems.Count == 1) { SubItems.Add(((IResourcePolicy)Data).ResourcePolicyEnabled.ToString()); }

    Read the article

  • C# Closing a form during a constructor

    - by pm_2
    Is it possible to close a form while the constructor is executing (or simply to stop it showing at this stage)? I have the following code: public partial class MyForm : Form { public MyForm() { if (MyFunc()) { this.Close(); } } } Which errors in Main(), here: static void Main() { ... // Following line errors Application.Run(new MyForm()); } I’ve tried checking the result of MyForm like this: static void Main() { ... MyForm frm = new MyForm(); if (frm != null) { // Following line errors Application.Run(frm); } } But that doesn’t seem to help. Can anyone tell me a way around this, please? Maybe a way to check the form to see if it still exists?

    Read the article

  • How to expose a control collection to a property grid at design time

    - by Stefano Delendati
    I have a custom control that with a property that is a collection of custom object. This custom object hava a reference to some component/controls. When at design time I tray to add an item to the collection and select the object, VS tells me that the control is not serializable. This is the code (simplified version - but not to much): public class ViewRefObj { public control view { get; set; } public ViewRefObj() { } } private List<ViewRefObj> _controls=new List<ViewRefObj>(); public List<ViewRefObj> Views { get { return _controls; } }

    Read the article

  • C# TabControl - is it possible to "disable" individual TabPages?

    - by CaldonCZE
    Is it somehow possible to disable one (or more) tabs of tab control? At some point I need to make user stay on the active tab and prevent him from leaving... I know I can disable the whole TabControl component, but that disables also all components on active tab... I also tried to use the Selecting method of TabControl: private void TabControl_Selecting(object sender, TabControlCancelEventArgs e) { e.Cancel = PreventTabSwitch; } This works, prevents user from switching (if PreventTabSwitch==true), but since all tabs look active and just don't react it's confusing... There is no Enabled property for individual tab pages, so I don't know what else to do... Thanks a lot for in advance for all tips.

    Read the article

  • how to shift windows forms controls?

    - by Mike
    How can i get same functionality in windows forms as in the next example. When i have two links one beneath, and when i click first link a panel is visibleunder it and next link is shifted. When i click again the panel is invisible and second link shifted back. <script type="text/javascript"> function toggleDivState(divName) { var ctl = window.document.getElementById(divName); if (ctl.style.display == "none") ctl.style.display = ""; else ctl.style.display = "none"; } </script> <a href="javascript:toggleDivState('poll<%# Eval("ID") %>');"> <div style="display: none;" id="poll<%# Eval("ID") %>">

    Read the article

  • Change row/column span programatically (tablelayoutpanel)

    - by alex
    I have a tablelayoutpanel. 2x2 - 2 columns 2 rows. For example, I added a button button1 in a 1 row, second column. button1 has a dock property set to Fill. VS Designer allows to set column/row span properties of button1. I want an availability to change row span property of button1 programatically, so it can fill all second column(1 row and second row) and availability to set it back. How ?

    Read the article

  • DataGridView error when set DataSource

    - by user264464
    I got an error when run datagridview.DataSource = dataView; dataview is correct. I can see data inside it when I debug program. I got next error "Object reference not set to an instance of an object." Any Ideas? code: this.datagridview = new System.Windows.Forms.DataGridView(); ... DataSet ds = new DataSet(); XmlReaderSettings settings = new XmlReaderSettings(); StringReader stringReader = new StringReader(retString); XmlReader xmlReader = XmlReader.Create(stringReader, settings); ds.ReadXml(xmlReader); DataView dataView = ds.Tables[0].DefaultView; dataView is not null. I am able to view it when debug

    Read the article

  • Do I really have to call Focus in OnMouseDown of my custom Control?

    - by Thomas
    I'm implementing a custom control that inherits from Control. I want it to be focusable (it's a kind of list box). In the constructor, I do SetStyle(ControlStyles.Selectable, true); I can now use Tab to navigate to the control. However, when the control receives a mouse click, it does not automatically claim focus. I can work around this, of course: protected override void OnMouseDown(MouseEventArgs e) { Focus(); base.OnMouseDown(e); } But this feels like a kludge that should not be necessary. Is this really the way to go? Or is there some way to tell Control to claim focus automatically when it receives a mouse click?

    Read the article

  • C# NetworkAvailibilityChanged doesn't trigger on disconnect

    - by Nickolay Kondratyev
    My goal is to detect when the Ethernet cable gets disconnected I am attempting to use NetworkChange class but the event NetworkAvailibilityChanged does not trigger when I unplug Ethernet cable. NetworkAddressChanged does get triggered in about 8 seconds but NetworkAvailibilityChanged never does, is there is anything am I am missing? public partial class Form1 : Form { public Form1() { InitializeComponent(); NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged); NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged); } void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e) { Console.WriteLine("NetworkChange_NetworkAvailabilityChanged"); } void NetworkChange_NetworkAddressChanged(object sender, EventArgs e) { Console.WriteLine("NetworkChange_NetworkAddressChanged"); } }

    Read the article

  • How to create a separate thread to do some operation periodically and update UI in WPF?I'm stack

    - by black sensei
    Hello Experts! I'm trying to do a periodic separated thread operation let's say check for internet connection or check for user's info via web service and update the user interface. i've tried with quartz.net to implement that.So i created an inner class for the window i need to update.That inner class does what is meant for but the problem is that i don't know how to access parent's(window class) members form the child(inner class). for example public partial class Window2 : Window { private int i; public Window2() { InitializeComponent(); } public string doMyOperation() { //code here return result; } public class Myclass :IJob { public void Execute(JobExecutionContext context) { string result = doMyOperation(); //Now here i could be able to call a label of name lblNotif //lblNotif.Content = result; } } } Well the whole idea works but i'm stacked at here i need to access a controls of Window2 Since i'm stacked i tried Spring.Net way of implementing Quartz hoping that i could use MethodInvokingJobDetailFactoryObject and rather have the Operation done on Window2 itself.But for some reason i'm having an exception Cannot resolve type [System.Windows.Window2,System.Windows];, could not load type from string value System.Windows.Window2,System.Windows and the wiring is done so <object name="UpdateLabelJob" type="System.Windows.Window2,System.Windows"/> What i'm i doing wrong here?Is that a way round? thanks for reading and for helping out

    Read the article

  • Keyword Implementation in C#

    - by j-t-s
    Hi All Is there a way, and how would I go about implementing my own keyword such as in, and as (etc), to be used in my code? Here is what I had in mind. I want to (just for my own personal reasons, I guess) add a few keywords of my own, one of which would be the "was" keyword: if(Control was Clicked) { // etc etc }

    Read the article

  • Validating event usurps button click on Windows Form

    - by triskelion
    I have a ComboBox and a Save button on my Windows Form. When I change the selected value in the ComboBox then click the Save button, the ComboBox validating event fires but the button click is lost. When the selected value is valid this results in the user thinking they have saved the change when in fact they have not. Why is the button click lost if the ComboBox is valid? Is there a work around?

    Read the article

  • DBConcurrencyException happening on second delete

    - by Malfist
    My code keeps throwing a DBConcurrencyException ("Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.) when I make a second update to the data table. The problem actually happens on a table that is linked to a parent table. The two tables, CashReceipts and CashReceiptsApplyTo are displayed on the same winform, and when I delete two cash receipts the update on cash receipt apply to's table fails with the dbconcurrencyexception (the table is updated everytime the binding source [linked to a binding navigator] changes position). Here is my code: protected override void saveToDatabase() { tblCashReceiptsBindingSource.EndEdit(); tblCashReceiptsTableAdapter.Update(rentalEaseDataSet.tblCashReceipts); //update the datatable foreach (DataGridViewRow viewRow in viewApplications.Rows) { if (viewRow.Cells[colAppID.Index].Value == null || viewRow.Cells[colApplyTo.Index].Value == null) { continue; } else if ((int)viewRow.Cells[colAppID.Index].Value == -1) { insertNewRow(viewRow); } else { updateRow(viewRow); } } try { tblCashReceiptsApplyToTableAdapter.Update(rentalEaseDataSet.tblCashReceiptsApplyTo); //tblCashReceiptsApplyToTableAdapter.Fill(rentalEaseDataSet.tblCashReceiptsApplyTo); ); } catch (Exception e) { Bitmap bitmap = new Bitmap(this.Width, this.Height); this.DrawToBitmap(bitmap, new Rectangle(0, 0, this.Width, this.Height)); saveScreenshot(this.GetType().FullName, e.Message, bitmap); MessageBox.Show("There was an error saving your changes. This means that you should close the form, and re-enter the last Receipt you entered.\n\nPlease report this."); } } The insertNewRow, and updateRow are simple: private void updateRow(DataGridViewRow viewRow) { //be forgiving if ((int)viewRow.Cells[colAppID.Index].Value == -1) { insertNewRow(viewRow); return; } //find row in table, if it's not there, crash and burn RentalEaseDataSet.tblCashReceiptsApplyToRow updateRow = rentalEaseDataSet.tblCashReceiptsApplyTo.Select("ID = " + viewRow.Cells[colAppID.Index].Value.ToString())[0] as RentalEaseDataSet.tblCashReceiptsApplyToRow; updateRow.BeginEdit(); updateRow.CashReceiptsID = (int)viewRow.Cells[colCashReceipt.Index].Value; updateRow.ApplyTo = (int)viewRow.Cells[colApplyTo.Index].Value; updateRow.Paid = CurrencyToDecimal(viewRow.Cells[colPaid.Index].Value); if (viewRow.Cells[colMemo.Index].Value != null) { updateRow.Memo = viewRow.Cells[colMemo.Index].Value.ToString(); } else { updateRow.SetMemoNull(); } updateRow.EndEdit(); } private void insertNewRow(DataGridViewRow viewRow) { //be forgiving if ((int)viewRow.Cells[colAppID.Index].Value != -1) { updateRow(viewRow); return; } RentalEaseDataSet.tblCashReceiptsApplyToRow newRow = rentalEaseDataSet.tblCashReceiptsApplyTo.NewRow() as RentalEaseDataSet.tblCashReceiptsApplyToRow; newRow.CashReceiptsID = (int) viewRow.Cells[colCashReceipt.Index].Value; newRow.ApplyTo = (int) viewRow.Cells[colApplyTo.Index].Value; newRow.Paid = CurrencyToDecimal(viewRow.Cells[colPaid.Index].Value); if (viewRow.Cells[colMemo.Index].Value != null) { newRow.Memo = viewRow.Cells[colMemo.Index].Value.ToString(); } rentalEaseDataSet.tblCashReceiptsApplyTo.Rows.Add(newRow); //update the ID viewRow.Cells[colAppID.Index].Value = newRow.ID; } Any idea why it would throw that error on the second delete?

    Read the article

  • open a text file only if not opened alread (open in NotePad)

    - by Mr_Green
    In my project, I am trying to open a text file. Well the below code works but when the user click the button again and again, many files are being opened. (which I dont want) System.Diagnostics.Process.Start(filePath); I also tried Link , File.Open and File.OpenText which are not opening the text file and also not showing any error (tried with try catch block) File.Open(filePath); (or) File.OpenText(filePath); (or) FileStream fileStream = new FileStream(filePath, FileMode.Open); I also tried this: (ERROR : Cannot be accessed with instance reference qualify with a type name instead) System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.Start(filePath); /*red scribbles here*/ proc.WaitForExit(); How to show only one instance of the Text file(.txt). am I doing something wrong in my attempts? please suggest. EDIT: I want to open other text files afterwards but not the same and also the application should be accessible after opening a text file(or many). I have only one form.

    Read the article

  • Can anyone explain why this behaviour might be happening in Windows Forms?

    - by gizgok
    I'm developing a Windows Forms Application. See attached image for the Interface. Now I've put a close button (X) in the Panel(say Panel2) which has Application Constants as label.The first combo box is in another panel(say Panel1). Now when I click on the X button in Panel 2 I want the Panel to be invisible and the combo box text to be blank. Simple enough. So I write Panel2.visible=false; comboBox1.SelectedIndex=-1; When I click on X, the text in combo box goes blank, then I have to click again for the Panel2 to go invisible. Then I changed the sequence comboBox1.SelectedIndex=-1; Panel2.visible=fasle; and this works smooth. Not sure why this might be happening? Is there anything that I might be doing with my form design/code to have such a behaviour?

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >