Search Results

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

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

  • C# drawing and invalidating 2 lines to meet

    - by BlueMonster
    If i have 2 lines on a page as such: e.Graphics.DrawLine(blackPen, w, h, h, w); e.Graphics.DrawLine(blackPen, w2, h2, h2, w2); how would i animate the first line to reach the second line's position? I have the following method which calculates the distance between two points (i'm assuming i would use this?) public int Distance2D(int x1, int y1, int x2, int y2) { // ______________________ //d = &#8730; (x2-x1)^2 + (y2-y1)^2 // //Our end result int result = 0; //Take x2-x1, then square it double part1 = Math.Pow((x2 - x1), 2); //Take y2-y1, then sqaure it double part2 = Math.Pow((y2 - y1), 2); //Add both of the parts together double underRadical = part1 + part2; //Get the square root of the parts result = (int)Math.Sqrt(underRadical); //Return our result return result; } How would i re-draw the line (on a timer) to reach the second line's position? I've looked a lot into XAML (story-boarding) and such - but i want to know how to do this on my own. Any ideas? I know i would need a method which runs in a loop re-drawing the line after moving the position a tid bit. I would have to call Invalidate() in order to make the line appear as though it's moving... but how would i do this? how would i move that line slowly over to the other line? I'm pretty sure i'd have to use double buffering if i'm doing this as well... as such: SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); This doesn't quiet work, i'm not quiet sure how to fix it. Any ideas? protected override void OnPaint(PaintEventArgs e) { Distance2D(w, h, w2, h2); if (w2 != w && h2 != h) { e.Graphics.DrawLine(blackPen, (w * (int)frame), (h * (int)frame), (h * (int)frame), (w * (int)frame)); e.Graphics.DrawLine(blackPen, w2, h2, h2, w2); } else { t.Abort(); } base.OnPaint(e); } public void MoveLine() { for (int i = 0; i < 126; i++) { frame += .02; Invalidate(); Thread.Sleep(30); } } private void button1_Click(object sender, EventArgs e) { t = new Thread(new ThreadStart(MoveLine)); t.Start(); }

    Read the article

  • Getting a NullReferenceException Error when invoking a Select File Dialog Box

    - by codingguy3000
    Hey everyone This is a real newbie question. I have simple app that selects a picture and display's that picture in a PictureBox. I decided to mess with the Opacity Attribute so I added a timer and created this cool effect where the Main Form's Opacity is increased by 20% every 400 miliseconds. The problem is that now when I click the button that invokes the Select File Dialog Box I'm getting a NullReferenceException error. private void tmrClock_Tick(object sender, EventArgs e) { if (ViewerForm.ActiveForm.Opacity != 1) { ActiveForm.Opacity = ActiveForm.Opacity + .20; } } The error message is pointing to the if statement. What am I doing wrong? Thanks

    Read the article

  • DataGridView formatting

    - by Vadim
    I have a DGV with columns "code" and "name". Depends of lenght of a code I want to add tabulation to the "name" cells, to show structure of a data. Like that in this picture: How is it better to do? I think there is a better way then just loop for all rows and add spaces in front of names, right?

    Read the article

  • How can I tell when the Text of a System.Windows.Forms.GroupBox wraps to the next line?

    - by fre0n
    I'm creating a GroupBox at runtime and setting its Text property. Usually, the text is only on one line, but sometimes it wraps. The problem is that the controls contained in the GroupBox cover up the GroupBox's text. What I'd like to do is determine if and when the text wraps. Specifically, I'd like to determine how much extra height the wrapped text takes up as compared to a single line. That way, I can reposition the GroupBox's controls and adjust its height. Initially, I thought I'd do this by calling the GroupBox's CreateGraphics() method, and using the Graphics to measure the string. Something like this: private void SetGroupBoxText(GroupBox grp, string text) { const int somePadding = 10; Graphics g = grp.CreateGraphics(); SizeF textSize = g.MeasureString(text, grp.Font); if (textSize.Width > (grp.Width - somePadding)) { // Adjust height, etc. } } The problem is that the size generated by g.MeasureString(text, grp.Font) doesn't seem to be accurate. I determined that it wasn't accurate by putting enough of a single character to cause a wrap, then measuring the resulting string. For example, it took 86 pipes (|) to until a wrap happened. When I measured that string, its width was ~253. And it took 16 capital W's to force a wrap - its string had a width of ~164. These were the two extremes that I tested. My GroupBox's width was 189. (a's took 29 and had a width of ~180, O's took 22 and had a width of ~189) Does anyone have any ideas? (hacks, WinAPI, etc. are welcome solutions)

    Read the article

  • 'Timeout Expired' error against local SQL Express on only 2 LINQ Methods...

    - by Refracted Paladin
    I am going to sum up my problem first and then offer massive details and what I have already tried. Summary: I have an internal winform app that uses Linq 2 Sql to connect to a local SQL Express database. Each user has there own DB and the DB stay in sync through Merge Replication with a Central DB. All DB's are SQL 2005(sp2or3). We have been using this app for over 5 months now but recently our users are getting a Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Detailed: The strange part is they get that in two differnt locations(2 differnt LINQ Methods) and only the first time they fire in a given time period(~5mins). One LINQ method is pulling all records that match a FK ID and then Manipulating them to form a Heirarchy View for a TreeView. The second is pulling all records that match a FK ID and dumping them into a DataGridView. The only things I can find in common with the 2 are that the first IS an IEnumerable and the second converts itself from IQueryable - IEnumerable - DataTable... I looked at the query's in Profiler and they 'seemed' normal. They are not very complicated querys. They are only pulling back 10 - 90 records, from one table. Any thoughts, suggestions, hints whatever would be greatly appreciated. I am at my wit's end on this.... public IList<CaseNoteTreeItem> GetTreeViewDataAsList(int personID) { var myContext = MatrixDataContext.Create(); var caseNotesTree = from cn in myContext.tblCaseNotes where cn.PersonID == personID orderby cn.ContactDate descending, cn.InsertDate descending select new CaseNoteTreeItem { CaseNoteID = cn.CaseNoteID, NoteContactDate = Convert.ToDateTime(cn.ContactDate). ToShortDateString(), ParentNoteID = cn.ParentNote, InsertUser = cn.InsertUser, ContactDetailsPreview = cn.ContactDetails.Substring(0, 75) }; return caseNotesTree.ToList<CaseNoteTreeItem>(); } AND THIS ONE public static DataTable GetAllCNotes(int personID) { using (var context = MatrixDataContext.Create()) { var caseNotes = from cn in context.tblCaseNotes where cn.PersonID == personID orderby cn.ContactDate select new { cn.ContactDate, cn.ContactDetails, cn.TimeSpentUnits, cn.IsCaseLog, cn.IsPreEnrollment, cn.PresentAtContact, cn.InsertDate, cn.InsertUser, cn.CaseNoteID, cn.ParentNote }; return caseNotes.ToList().CopyLinqToDataTable(); } }

    Read the article

  • Mvp View knows Model

    - by userbb
    I'm trying to use MVP and I notice that my View must know Model that should not happen in MVP I presume. here is example: public partial class TestForm : Form, ITestPresenter { public void LoadList(IEnumerable<AppSignature> data) { testPresenterBindingSource.DataSource = data; } } public interface ITestPresenter { event EventHandler<EventArgs> Load; void LoadList(IEnumerable<AppSignature> data); } and the problem is that in TestForm I need reference to AppSignature. In all tutorials I saw, there are some simple examples like public void LoadList(IEnumerable<String> data) where there is no need reference to model. But how i.e DataGridView can publish current row data?

    Read the article

  • LINQ 2 SQL Insert Error(with Guids)

    - by Refracted Paladin
    I have the below LINQ method that I use to create the empty EmploymentPLan. After that I simply UPDATE. For some reason this works perfectly for myself but for my users they are getting the following error -- The target table 'dbo.tblEmploymentPrevocServices' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. This application is a WinForm app that connects to a local SQL 2005 Express database that is a part of a Merge Replication topology. This is an INTERNAL App only installed through ClickOnce. public static Guid InsertEmptyEmploymentPlan(int planID, string user) { using (var context = MatrixDataContext.Create()) { var empPlan = new tblEmploymentQuestionnaire { PlanID = planID, InsertDate = DateTime.Now, InsertUser = user, tblEmploymentJobDevelopmetService = new tblEmploymentJobDevelopmetService(), tblEmploymentPrevocService = new tblEmploymentPrevocService() }; context.tblEmploymentQuestionnaires.InsertOnSubmit(empPlan); context.SubmitChanges(); return empPlan.EmploymentQuestionnaireID; } }

    Read the article

  • Add/Edit Columns in DataBound DataGrid

    - by Dave
    I've got a datagrid that is databound from a database table. How do I: a) Edit the displayed value for a column using the values from other columns in the row? (For example, display a URL like: <a href="/url?param=columnA">columnB</a> where columnA is the value from column A and columnB is the value from columnB) b) Add an additional column using values from the other columns (similar to a.)

    Read the article

  • Form.Show() is not showing it's child controls

    - by Refracted Paladin
    I have a form, frmPleaseWait, that has a MarqueeProgressBar and a Label that I want to use when the UI is loading the data in a poorly structured app we have. The problem is that frmPleaseWait.Show() shows the form but not the controls in it. It is just a white rectangle. Now frmPleaseWait.ShowDialog() shows the child controls but doesn't let the UI load it's data. What am I missing? Below is a code snippet from where I am trying this. PleaseWait = new frmPleaseWait(); PleaseWait.Show(this); // Set all available HUD values in HUD Object HUD.LastName = GetCurrentRowVal("LastName").Trim(); HUD.FirstName = GetCurrentRowVal("FirstName").Trim(); HUD.PersonId = Convert.ToInt32(GetCurrentRowVal("PersonID").Trim()); HUD.SSn = GetCurrentRowVal("SSN").Trim(); HUD.MiddleName = GetCurrentRowVal("MiddleName").Trim(); HUD.MasterID = ConnectBLL.BLL.DriInterface.CheckForDriId(HUD.PersonId).ToString(); // This loads numerous UserControls with data shellForm.FormPaint(HUD.PersonId); PleaseWait.Close();

    Read the article

  • How do I fix the alpha value after calling GDI text functions?

    - by Daniel Stutzbach
    I have a application that uses the Aero glass effect, so each pixel has an alpha value in addition to red, green, and blue values. I have one custom-draw control that has a solid white background (alpha = 255). I would like to draw solid text on the control using the GDI text functions. However, these functions set the alpha value to an arbitrary value, causing the text to translucently show whatever window is beneath my application's. After calling rendering the text, I would like to go through all of the pixels in the control and set their alpha value back to 255. What's the best way to do that? I haven't had any luck with the BitBlt, GetPixel, and SetPixel functions. They appear to be oblivious to the alpha value. Here are other solutions that I have considered and rejected: Draw to a bitmap, then copy the bitmap to the device: With this approach, the text rendering does not make use of the characteristics of the monitor (e.g., ClearText). Use GDI+ for text rendering: This application originally used GDI+ for text rendering (before I started working on Aero support). I switched to GDI because of difficulties I encountered trying to accurately measure strings with GDI+. I'd rather not switch back. Set the Aero region to avoid the control in question: My application's window is actually a child window of a different application running in a different process. I don't have direct control over the Aero settings on the top-level window. The application is written in C# using Windows Forms, though I'm not above using Interop to call Win32 API functions.

    Read the article

  • LINQ EF not saving to database...

    - by Keith Barrows
    I guess this is a continuation of the last question I asked: http://stackoverflow.com/questions/2587542/bulk-insert-and-update-with-ado-net-entity-framework. I am not getting any errors while doing inserts yet no data is actually going into my DB. My DB is a SDF file (SQL CE). Any ideas what to check? My app.config looks like: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="Lab_Use_Billing.Properties.Settings.LabUseConnectionString" connectionString="Data Source=|DataDirectory|\Models\LabUse.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" /> <add name="LabUseEntities" connectionString="metadata=res://*/Models.LabUseEntities.csdl|res://*/Models.LabUseEntities.ssdl|res://*/Models.LabUseEntities.msl; provider=System.Data.SqlServerCe.3.5; provider connection string=&quot;Data Source=|DataDirectory|\Models\LabUse.sdf&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration> TIA

    Read the article

  • Panel in Windows Forms Application not clearing

    - by SwiftStriker00
    I'm working on my project: [Beer Pong Management System][1], a Windows Forms application. I am currently trying to add a whole tournament mode to it. In a nutshell, I've created a TabControl, with the first tab page with the settings and setup and the second page the brackets. There is a feature for each of the match-ups, that once there is a winner is decided, a yellow cancel button will appear in order to revert the tournament. However my issue is when i click the button the next match-up does not get removed in the series is going. See below: Image Here(not high enough rep to insert image) I have tried to set the MatchUp to null, I've tried dispose(), close(). even Parent.Controls.Remove(). Even after I switch tabs which is supposed to clear all, they still sit there when i come back. I have a feeling I might be loosing a reference or something because I can't even push new teams into them, they just sit there with their buttons. Does anyone have any tips or know of any known issues that might be causing this? Thanks. [1] _http://www.cs.rit.edu/~rmb1201/pages/code.shtml

    Read the article

  • How to make this open a webbrowser inside a new form

    - by user335932
    private void button5_Click(object sender, EventArgs e) { if (domainUpDown2.Text == "Battlefield: Bad Company 2") { Form2 form2 = new Form2(); form2.ShowDialog(); } } All that does is open a new blank form, but i need it to open a new form with a webbrowser in it so i can set it url dependent on the if statement..

    Read the article

  • Avoid Flickering in Windows Forms?

    - by user1733909
    Double buffering not working with combo-box. is there any another methods to avoid flickering in windows forms? i have one windows form with number of panels in it. I'm showing only one panel at a time based on my menu selection. i have one icon panel,one header panel and the combo box. based on the selected item of that combo-box the gridview1 and 2 are filling. when I'm rapidly selecting the combo-box item using my keyboard down arrow the icon panel and the header panel are always repainting. i need to keep that both without any change. this two panels producing some flashing effect(ie,they are blinking or flashing) while I'm changing the combo box selected index. is there any way to avoid this flashing.? i tried double-buffered enabled in form constructor and form load event. Please Help..............

    Read the article

  • How to load mht from stream/string into a WebBrowser control?

    - by Sameh Serag
    The WebBrowser control loads properly any mht file if I use the Navigate method, but when I use the DocumentText or DocumentStream properties, the source of the mht file is displayed as if I opened the file in notepad. If I write the stream to a temp file then Navigate to it, it works properly, but I don't want to do it this way. This issue seems common, but I didn't find a working solution for it. Some people suggest I should fool IE by implementing IPersistMoniker com interface, ...etc. I have tried with this a little bit, but unfortunately I got the same result. May be I have done something wrong. I still feel their should be a more straightforward solution (other than saving in a temp file first), any idea?

    Read the article

  • How would I initialize these two lists so that modifying one doesn't modify the other?

    - by Brandon
    I'm aware of why this is happening, but is there any way to do this without having to implement ICloneable or a Copy() method? Preferably .net 2.0, but 3.5 is fine if it is necessary. Essentially I'm trying to implement an undo method. In most cases I can just perform the reverse action in the Undo(), but for others that is not possible. So I want to keep two lists. One for the list of items that I will be modifying, and one for the original, unmodified list of items. This way if I need to do an undo, I just delete the modified items and replace them with the originals. Most of the ways I've tried to assign the _originalItems variable doesn't work, so what would I need to do? public MyClass(List<SelectedItems> selectedItems) { _selectedItems = new List<SelectedItems>(selectedItems); _originalItems = ?? }

    Read the article

  • How to close a form in UserControl

    - by FJPoort
    I created a UserControl with the buttons Save, Close and Cancel. I want to close the form without saving on the Cancel button, prompt a message to save on the Close button and Save without closing on the Save button. Normally, I would have used this.Close() on the Cancel button, but the UserControl doesn't have such an option. So I guess I have to set a property for that. Scrolling down the "Questions that may already have your answer" section, I came across this question: How to close a ChildWindow from an UserControl button loaded inside it? I used the following C# code: private void btnCancel_Click(object sender, EventArgs e) { ProjectInfo infoScreen = (ProjectInfo)this.Parent; infoScreen.Close(); } This does the job for one screen, but I wonder if I have to apply this code for all the screen I have? I think there should be a more efficient way. So my question is: Do I need to apply this code for every form I have, or is there another (more efficient) way?

    Read the article

  • How to show controls hierarchy in Winform designer

    - by Cédric V
    Hi, One of our client has an old winform application that contains forms with a lot of controls on them. Some of those controls have a deep hierarchy and that make it to hard to select them in the designer. I would need to understand this hierarchy to make modification and correct some bugs, is there a tools, plugin or something to be able to clearly see this hierarchy ? Something like in the aspx source when you have a breadcrumb of where you are in the HTML hierarchy (HTML Body div etc ...) or something more visual maybe ? Any ideas ? PS : we use Visual Studio 2008, .NET 2.0

    Read the article

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