Search Results

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

Page 48/113 | < Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >

  • How do I pass a reference type to Control.Invoke / display a form centered on the main form

    - by Rubio
    I'm on a thread other than the UI thread and need to display a modal form that's centered on the application's main form. What I usually do is use the width and height of the main form and the modal form to calculate the location, then use the PointToScreen method of the main form to get the location of the modal form. Since I'm on another thread I need to use Control.Invoke to call this method. I just can't figure out how to pass a parameter of type Point to Control.Invoke (params object[]). Value types and String works fine. Or, if someone can find a better way to display a form centered on the main form regardless of thread, that would be great. MessageBox seems to be able to do this (although not modally).

    Read the article

  • drag to pan on an UserControl

    - by Matías
    Hello, I'm trying to build my own "PictureBox like" control adding some functionalities. For example, I want to be able to pan over a big image by simply clicking and dragging with the mouse. The problem seems to be on my OnMouseMove method. If I use the following code I get the drag speed and precision I want, but of course, when I release the mouse button and try to drag again the image is restored to its original position. using System.Drawing; using System.Windows.Forms; namespace Testing { public partial class ScrollablePictureBox : UserControl { private Image image; private bool centerImage; public Image Image { get { return image; } set { image = value; Invalidate(); } } public bool CenterImage { get { return centerImage; } set { centerImage = value; Invalidate(); } } public ScrollablePictureBox() { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); Image = null; AutoScroll = true; AutoScrollMinSize = new Size(0, 0); } private Point clickPosition; private Point scrollPosition; protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); clickPosition.X = e.X; clickPosition.Y = e.Y; } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button == MouseButtons.Left) { scrollPosition.X = clickPosition.X - e.X; scrollPosition.Y = clickPosition.Y - e.Y; AutoScrollPosition = scrollPosition; } } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.FillRectangle(new Pen(BackColor).Brush, 0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height); if (Image == null) return; int centeredX = AutoScrollPosition.X; int centeredY = AutoScrollPosition.Y; if (CenterImage) { //Something not relevant } AutoScrollMinSize = new Size(Image.Width, Image.Height); e.Graphics.DrawImage(Image, new RectangleF(centeredX, centeredY, Image.Width, Image.Height)); } } } But if I modify my OnMouseMove method to look like this: protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button == MouseButtons.Left) { scrollPosition.X += clickPosition.X - e.X; scrollPosition.Y += clickPosition.Y - e.Y; AutoScrollPosition = scrollPosition; } } ... you will see that the dragging is not smooth as before, and sometimes behaves weird (like with lag or something). What am I doing wrong? I've also tried removing all "base" calls on a desperate movement to solve this issue, haha, but again, it didn't work. Thanks for your time.

    Read the article

  • Change color of text within a RichTextBox in C#

    - by Addie
    I have a RichTextBox that I write a string to every time I click a Form button. The string ends with a newline so each time I add a string, it appends to the bottom of the RichTextBox. Each string begins with the string "Long" or "Short" and ends with Environment.NewLine. I'd like to color each line red if it beings with "Long" and blue if it begins with "Short". How can I do this? If you need further clarification of the question comment below.

    Read the article

  • Flowlayout panel and autosizing child controls doesn't work

    - by Pete
    I am trying to get a very simple autosizing layout on a winform (C# .NET). I've tried TableLayoutPanels and FlowLayoutPanels but nothing works. I have a usercontrol which is a container for other usercontrols which are created at runtime - I've called it StackPanel as I want it to list the child controls vertically. I've tried this using a FlowLayoutPanel, TableLayoutPanel and a Panel (with each control docked to the top). The child usercontrol consists of a label and then any number of radiobuttons (or any other standard control - it doesn't matter). When the child controls are created, the label text is set (if this is long it needs to wrap to a new line) and the radio buttons are added. There seems to be no combination of docking/autosizing or manual size setting using the Resize events that can get everything to show without clipping and still resize with the form. Thanks!

    Read the article

  • How can I obtain a list of modified files within a 'changeset' range from team foundation server thr

    - by Colin W
    I'm trying to create a tool which will help my team perform code reviews on a more regular basis without it's usual massive overhead. At the moment the manual process involves using Team Foundation Sidekicks to identify the Changesets and then exporting that to excel to filter the results to find which items need to be reviewed (e.g. code files). I've heard mention of using a TFS API, but found very little help online possibly because I was asking google 'the wrong questions'.

    Read the article

  • Expression Blend 2/WPF Book

    - by Michael Damatov
    I'm looking for an Expression Blend 2 book that includes best-practices (Expression Blend 2/Visual Studio 2008) designer perspective (Expression Blend 2) programmer perspective (interoperability with Visual Studio 2008) How-To-chapters for Windows Forms developers (how to solve the same problem with WPF) Could you make a recommendation?

    Read the article

  • Accessing non-static combbox property in the static method.

    - by Harikrishna
    I have one combobox on the window form and I have one method which is declared with static like private static DataTable ParseTable(HtmlNode table) Now I want to use combobox in that method for using combobox property but I can not access any property of combobox or combobox itself.If I made the combobox declaration as static then it can be accessed in that static method.But any alternative way to access combbox property in that static method because I don't want to make combobox declaration as static.

    Read the article

  • Sorting a GridView

    - by Markus
    Hi, I have a question regarding GridView windows forms control. As a datasource, I am using a DataTable object. When the grid view is sorted, the DataTable's row indices are not sorted. In this way, when accessing the DataTable using indices from GridView, I get the unexpected rows. How can this situation be handled?

    Read the article

  • C# Button Text Unicode characters.

    - by Fossaw
    C# doesn't want to put Unicode characters on buttons. If I put \u2129 in the Text attribute of the button, the button displays the \u2129, not the Unicode character, (example - I chose 2129 because I could see it in the font currently active on the machine). I saw this question before, link text, but the question isn't really answered, just got around. I am working on applications which are going all over the world, and don't want to install all the fonts, more then "don't want", there are that many that I doubt the machine I am working on has sufficient disk space. Our overseas sales agents supply the Unicode character "numbers". Is there another way forward with this? As an aside, (curiosity), why does it not work?

    Read the article

  • .NET: How to know when serialization is completed?

    - by Ian Boyd
    When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding more rows and columns. After serialization is complete, I need to clear everything and re-initialize the rows and columns. Is there a protected method that I can override to know when the control is done serializing? Of course, I'd prefer to not have to do the work in the constructor, throw it away, and do it again after (potential) serialization. Is there a preferred event that is the equivalent of "set yourself up now", so that it is called once whether I'm serialized or not? The serialization i speak of comes from the InitializeComponent() method in the form's code-behind file. #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { ... } It would have been perfect if InitializeComponent was a virtual method defined by Control, then i could just override it and then perform my processing after i call base: protected override void InitializeComponent() { base.InitializeComponent(); InitializeMe(); } But it's not an ancestor method, it's declared only in the code-behind file. i notice that InitializeComponent calls SuspendLayout and ResumeLayout on various Controls. i thought it could override ResumeLayout, and perform my initialization then: public override void ResumeLayout() { base.ResumeLayout(); InitializeMe(); } But ResumeLayout is not virtual, so that's out. Anymore ideas? i can't be the first person to create a custom control.

    Read the article

  • C#: standard Windows menu bars in Windows Forms

    - by BoltClock
    I noticed that adding a MenuStrip (from the VS Toolbox) to my form design doesn't yield a menu bar like many native Windows applications. Instead I get a menu bar like VS's own. None of the style settings for MenuStrip appear to mimic the much more common native menu bar. Is there a way to add a menu bar to my Windows Forms application that looks the same as the one you see in Notepad, Task Manager, Windows Explorer and others? (Preferably with the designer, but I wouldn't mind adding it programmatically either.)

    Read the article

  • Automatically resize TableLayoutPanel

    - by Armagan
    I have a programmatically created TableLayoutPanel. It works fine but I couldn't find something: how can I make it size columns automatically when the form is resized? The panel is set to Dock.Top and when I resize the form instead of sizing every column as percents, only last column grows. What can I do for this? Here's how I add ColumnStyle for each column: this.tablePanelFilter.ColumnStyles.Add( new ColumnStyle(SizeType.Percent,Convert.ToSingle( Math.Ceiling((decimal)100 / (decimal)columnCount))));

    Read the article

  • Read text file into listbox collections

    - by Arcadian
    Hi, i'm new to C#. I need my program to show different parts of the data contained in a txt file into different listboxs (which are on different tabs of a form) so that the user can see the particular block of data they are interested in. the data contained in the txt file looks like this: G30:39:03:31 JG06 G32:56:36:10 JG04 G31:54:69:52 JG04 G36:32:53:11 JG05 G33:50:05:11 JG06 G39:28:81:21 JG01 G39:22:74:11 JG06 G39:51:44:21 JG03 G39:51:52:22 JG01 G39:51:73:21 JG01 G35:76:24:20 JG06 G35:76:55:11 JG01 G36:31:96:11 JG02 G36:31:96:23 JG02 G36:31:96:41 JG03 though much more of it :) The separate listboxes will contain only the lines who's first integer pair matches that listbox's name. For example, all the lines that start "G32" will be added to the G32 listbox. I think the code would start something like: private void ReadToBox() { FileInfo file = new FileInfo("Jumpgate List.JG"); StreamReader objRead = file.OpenText(); while (!objRead.EndOfStream) but i'm not sure where to start in terms of getting it sorted yet. Any help? There's some rep in it for you :D

    Read the article

  • Simple regex question (C#, MS SQL)

    - by Vytas999
    Hello, I have some Regex, it looks like this: string regexForDrop = @"^((%27)|'|(\-\-))\s*(d|%64|%44)(r|%72|%52)(o|%6F|%4F)(p|%70|%50)$"; It works fine, when i write to the input "--drop", but it does not works, when i write "drop table users" or something like that. I need that it would be working, no matter what comes after "--drop". How i can implement that? Thanks

    Read the article

  • Change the style of WinForm border?

    - by Dodi300
    Is it possible to change the style of a WinForm border? I know that if the border is removed, it takes away the functionality to resize the program. Therefore is there a way to change the style of it? At the moment, I've removed the text from the border, set the "FormBorderStyle" to "SizableToolWindow" and set the "ControlBox" to false. That makes it look like this: But I want it to look something like this, but still be resizeable: (Maybe with a different color line)

    Read the article

  • How to get DataGridViewRow from CellFormatting event?

    - by tomaszs
    I have a DataGridView and handle event CellFormatting. It has a parameter called: DataGridViewCellFormattingEventArgs e With e.RowIndex in it. When i do: DataGridView.Rows[e.RowIndex] I get proper row from collection. But when I click at a header of a column to sort it by other column than default one and user DataGridView.Rows[e.RowIndex] I get unproper row. It is because Rows collection do not reflect order of rows in DataGridView. So how to get propert DataGridViewRow from RowIndex in DataGridView?

    Read the article

  • How to report DataContext.SubmitChanges() progress with LINQ2SQL

    - by kzen
    If there is a foreach loop that contains DataContext.Customer.InsertOnSubmit(cust) for example: foreach (Object obj in collection) { Customer cust = new Customer { Id = obj.Id, Name = obj.Name ... }; DataContext.Customer.InsertOnSubmit(cust); } And outside of the loop there is a call to: DataContext.SubmittChanges(); Is there a way to obtain the SubmittChanges progress in order to report the progress back to the user (or a different approach without moving the SubmittChanges into the loop)?

    Read the article

  • Handle ConstraintException and get ColumnName that cause the error

    - by Mysterious
    Hello, I have a Table Machines that made of: ID = Identity , Primary , AutoIncrement,NOT NULL SN = Unique , String , NOT NULL Name =String now I am using a form to insert data into this table, and I am using BindingSource and ErrorProvider, I am handling Null and Empty string in the DataSet layer (partial class in the dataset.xsd), now when I try to end editing this.machinesBindingSource.EndEdit(); I got this error message: ex.Message = "Column 'SN' is constrained to be unique. Value '123' is already present." I know I entered a duplicated value but the question is HOW can I determine which the columnName that cause the error and re-write the error message entirely in different language I want to get the columnName and the wrong value thanks in advance

    Read the article

  • C# - How to change window state of Form, on a different thread?

    - by Dodi300
    Hello. Does anyone know how I can chage the window state of a form, from another thread? This is the code I'm using: private void button4_Click(object sender, EventArgs e) { string pathe = label1.Text; string name = Path.GetFileName(pathe); pathe = pathe.Replace(name, ""); string runpath = label2.Text; Process process; process = new Process(); process.EnableRaisingEvents = true; process.Exited += new System.EventHandler(process_Exited); process.StartInfo.FileName = @runpath; process.StartInfo.WorkingDirectory = @pathe; process.Start(); WindowState = FormWindowState.Minimized; } private void process_Exited(object sender, EventArgs e) { this.WindowState = FormWindowState.Normal; } It's meant to run a program and minimize, then return to the normal state once the program has closed. Although I get this error "Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on." Any idea how to get this to work? Thanks.

    Read the article

  • c# control location precision

    - by AC
    I need more precision then integer based locations when puttng controls on a form. It seems control.location only supports Point. Is there a work around for this? Point p = new Point(100, 200); this.Location = p;// this works of course PointF pF = new PointF(100.04f, 200.08f); this.Location = pF;// this does not work of course because Location expects a Point not PointF Is there some setting on the base form, or base control I can set to have more location precision?

    Read the article

< Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >