Questions tagged [winforms]

25386 questions
1

votes
2

answer
973

Views

Get all Checkboxes in Winform / UserControl by reflection

I would like to add a dynamic CheckAll() method to check all checkboxes declared in my class. I tried following code: class MyContol : UserControl { /// /// HIDDEN but there is plenty of checkboxes declaration /// private void CheckAll() { FieldInfo[] props = this.GetType().GetFields(); foreach (Fi...
mickro
1

votes
2

answer
2.7k

Views

Can I use a DrawItem event handler with a CheckedListBox?

I would like to override the text displayed when an item is added to a checked list box. Right now it is using obj.ToString(), but I want to append some text, without changing the objects ToString method. I have seen examples of handling the DrawItem event for ListBoxs, but when I try to implement t...
spainchaud
1

votes
2

answer
26.8k

Views

How to use KeyPressEvent in correct way

try to create HotKeys for my forms code private void FormMain_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { MessageBox.Show("e"); } } works for one key, but if I whant to use combination of keys like CTRL+N, try to use if (e.KeyChar == (char)Keys.Enter &...
gbk
1

votes
2

answer
785

Views

C# redraw blinking

I have UserControl : Panel. When I add to Form own UserControl. UserControl.Anchor = Left|Right|Top|Bottom. When I resize Form Rectangle is blinking. How can you make that do not blink? public partial class UserControl1 : Panel { public UserControl1() { InitializeComponent(); this.ResizeRedraw = tru...
prm
0

votes
1

answer
33

Views

Timer keeps skipping 2 seconds after stopping and starting again

I have a timer that has a time value of 600 and interval of 1000 (1 second). When i stop the timer it hangs for 1 second and then skips 2 on the label. How do i fix this? Timer clock = new Timer(); int time; bool toggle = true; private void btnTimer_MouseClick(object sender, MouseEventArgs e) { if...
Masteprh33r
11

votes
3

answer
14.6k

Views

Using column name when using SqlDataReader.IsDBNull

Hello I have got this code which reads data from SQL DB. I don't know how should I edit it so I can use original column name and not column index. string query = "SELECT * FROM zajezd WHERE event='" + thisrow+ "' AND year='" + klientClass.Year() + "'"; SqlCommand cmd= new SqlCommand(query, spojeni);...
Marek
1

votes
1

answer
398

Views

Difference Between Mouse and Key events ToolStripMenuItem

So I'm having a bit of a problem handling a situation. I have an application, which is an MDI application, which opens custom documents. My MDI parent has a ToolStrip, with a few controls, a text box and a button. The text box holds a qty value for an item, then there is a button to add the item to...
Wanabrutbeer
1

votes
2

answer
1.4k

Views

DevExpress XAF - Display Format Of Grid View Group Footers

I am using DevExpress XAF and have enabled the Group Footer for grid views, i have then set this Group Footer to be the sum of all the records in that group which works fine. However the records are formatted as currency ({0:C}) and then in the Group Footer it calculates them correctly but just show...
Shwabster
1

votes
2

answer
2k

Views

Simple Application To Transfer File From Localhost To SFTP

I'm looking to create a simple desktop application that transfers a file from my local machine to an SFTP location. I have attempted the below, which transfers a file from my local machine to another location on my machine.. But struggling on how to transfer to an SFTP location, which uses a usernam...
Oam Psy
1

votes
2

answer
426

Views

Event handler deleted automatically

I create some event handler in Designer InitializeComponents(). The problem is, most of Event Handler that I create manually always disarpear (deleted) after I move another forms. For example, I create some Dragform in PictureBox like this: this.picLogo.MouseDown += picLogo_MouseDown; this.picLogo.M...
Jun Rikson
1

votes
1

answer
1.4k

Views

dynamically created radio buttons not displaying

I have an application in which there are several tabs. One of those creates several group boxes and in each of these group boxes I need 10 radio buttons ranging from 1-10. My problem is that I cannot get the radio button to show up and work properly. When I create them if I add them to the current t...
Brandon Gorcheff
0

votes
0

answer
10

Views

Increase performances of TableLayoutPanel - C#

I have made a TableLayoutPanel (Size 30x30) with each cell containing a button. However it takes multiples seconds for the TableLayoutPanel to generate itself. Is there ways to reduce this time? I already saw the SuspendLayout() and ResumeLayout() functions but they don't seem to improve the generat...
Valus_Paulus
1

votes
0

answer
16

Views

Unable to display second form after successful login validation

I am trying to use a progress bar in my windows form application the application validates the login credential on successful completion it displays another form but not able to display it as it has to appear it doesn't display any content and after few moments it gets me back to the original form...
Abrar Shaikh
1

votes
1

answer
3.3k

Views

How to get all Forms and User Controls in WinForms project?

I have a WinForms project, using Visual Studio 2013, DotNet Framework 4.0. How can I get a list of all of my created Forms and User Controls in the project, preferably at runtime? EDIT: Thanks for your reply. SO for example, I want to get the FOrms and User Controls under the namespace "MyApp.Forms"...
Tủn
1

votes
2

answer
2.8k

Views

How to fetch data from dynamically created textboxes (windows application)

I have used the below code to dynamically create textboxes by giving the total number of textboxes initially. After i enter values to these textboxes, how can i fetch the values from it. Like if i give count as 3, 3 textboxes will be created. Now, i enter data to each textbox. How can i read the val...
Gokul
-1

votes
0

answer
11

Views

Best Practice for the use of datasource

Recently I have been trying to rewrite how i handle data sources, instead of hard coding it. I would really like to migrate to using the intellisense method to hook up the variables to the UI. My Current Method went a little like this: Visuals_FriendlyRenderControl.DataBindings.Add("SelectedItem", S...
Offnix
0

votes
1

answer
27

Views

Resize rectangle with form Size in real time?

Here is the following rectangle below: When I resize the form, I need this rectangle to match the size of the form. When changing the width of the rectangle, do not interfere with its visibility within the form. I'm using the following: Note: I did the rectangle manually, but if you have rectangle r...
sYsTeM
1

votes
1

answer
278

Views

Custom Control in WPF as necessary as in Winforms?

During an interview, the company was asking about my use of custom controls in WPF. I have found with all of the power of the WPF way of creating a control (datatemplate, control template, styles,triggers etc... ) that having to write a custom control that overrides the OnRender method really hasn't...
AshbyEngineer
1

votes
1

answer
982

Views

Windows Forms Chart: Get mouse cursor coordinates in Chart axis scale?

I have a problem with the following sample: When I click at the place marked as '1' on my screenshot, I can get position in pixels by MouseClick event in a pretty easy way: private: System::Void chart1_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) { Point chartLoca...
irchris102
1

votes
1

answer
717

Views

To check whether thread's apartment type is MTA or STA?

Is there any way so that i can check the apartment type of thread,whether it is MTA or STA while debugging an application on runtime ? I am working on winforms application in visual studio 2008 IDE.
Mandar
1

votes
1

answer
4.1k

Views

Could not load file or assembly itextsharp

I had build setup file from my winform application. Then I installed it to my other computer, everything was working normally however when I clicked the SaveToPDF button which saves the gridview to pdf file I encountered with this error : Could not load file or assembly itextsharp, Version = 4.1.6...
BarisY
1

votes
3

answer
86

Views

Displaying Result in Windows Application

I am stuck with how to display the result in windows forms application. private void btnBrowse_Click(object sender, EventArgs e) { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { txtFileName.Text = openFileDialog1.FileName; } } private void btn_search_Click(obj...
0

votes
0

answer
8

Views

How would I make the points appear on a windows forms app?

I am trying to build a basic winforms application that draws a triangle from points I have specified, I cannot get the program to display the lines on the form whatsoever when the button is clicked. I am not very sure what code to put in the button. I am very new to c# and have some of the basics do...
BLAKE ELLIS
-1

votes
1

answer
23

Views

Why can't I detect Windows messages that are being sent to my CommonDialog? What is the right way of intercepting them?

I am trying to detect when the user clicks on a Form and a CommonDialog. Forms are fairly straightforward. I create a MessageFilter class that intercepts messages: class MessageFilter : IMessageFilter { private const int WM_LBUTTONDOWN = 0x0201; public bool PreFilterMessage(ref Message message) { if...
pushkin
1

votes
1

answer
520

Views

Replacing the System.Timers.Timer.Elapsed event when inheriting System.Timers.Timer

I'm creating a new class so that I can make the System.Timers.Timer class fit my needs just a little bit better. I create my new class like so... using System.Timers; class BtElapsedEventArgs : ElapsedEventArgs { //My extras } namespace MyGreatNewTimer { class BetterTimer : Timer { } } Now I simply...
Arvo Bowen
1

votes
1

answer
827

Views

How to hide the first index indicator column of DataGridView?

I don't know what is the exact name of that column, please see my screenshot.
ske
1

votes
2

answer
804

Views

Remove last row from listview

I'm using WinForms. I have a ListView with 2 columns in detail mode. I also have a button in my Form. When clicked, it adds different information to the listview. I placed a checkbox in my Form and i tried to delete the last row in the listview when it's checked, but i was having a hard time. How do...
taji01
0

votes
5

answer
42

Views

i have a string str=“75,75,83,84” i want remove duplicate from this in c# [on hold]

string str="75,75,83,84" I want to remove repeating values from the string, I provide one example of a string.string str+=Id.ToString() + ",";
Mulwaffer
1

votes
2

answer
1.5k

Views

Searching a treeview for a specific string

I'm trying to search a TreeView for a particular string, once I have found the index of the node, I wish to return its index and change the back color of that particular node, however my current code does not seem to be returning any matches, unless it's the root node: private void ApplyRulesetColor...
-1

votes
0

answer
16

Views

How to integrate datalogic megallan 8500XT scanner with windows 10 osin C# windows application.?

I m working over POS system using c# windows application in which i need to connect this datalogic scanner 8500Xt and scan the product. i am using dualTest software for fetching output. but not b able to get the output for any products. i m using RS232 single cable.! Please Please Help me for integr...
Komel Lakhani
0

votes
1

answer
49

Views

Can I make a switch statement to ask if a bool equals to true?

I'm writing a Tic Tac Toe game and want to check if the following buttons were clicked. (Which if true, means you have won.) I think a switch statement is more efficient for that, but its red underlined and I don't understand why. Here is my current code: using System; using System.Collections.Gene...
Hashinu
1

votes
1

answer
61

Views

Avoiding memory leaks with events

class Subscriber { private Publisher _publisher; void SomeMethod() { _publisher = new Publisher(); _publisher.SomeEvent += HandleEvent; } void HandleEvent(object sender, EventArgs e) { } } class Publisher { public event EventHandler SomeEvent; void FireEvent() { SomeEvent?.Invoke(this, EventArgs.Emp...
Signum
1

votes
1

answer
50

Views

My code about creating label dynamically in a loop don't work, only one appear

I'm creating an application, where for each Char in a txt file (where some text is written), a label containing one char letter from the txt is created and written. In the txt file, "Hello" is written, and only the H appear Here's my actual code : string test = System.IO.File.ReadAllText(@"../../.....
Chris
1

votes
4

answer
19.7k

Views

Richtextbox lines count

I'm developing a text editor in C#, and I'm trying to make a line count. private void updateNumberLabel() { Point pos = new Point(0, 0); int firstIndex = Document.GetCharIndexFromPosition(pos); int firstLine = Document.GetLineFromCharIndex(firstIndex); pos.X = ClientRectangle.Width; pos.Y = ClientRe...
Los799
0

votes
1

answer
17

Views

Can you use a string in the name of the control when setting its property?

I have a list box with a lot of items, and each item is supposed to open a panel next to it. When an item is clicked, it brings it's respective panel to the front (the panels are all positioned in the same place). I've tried using if statements to check the selected index, but this will result in 10...
cd5ssmffan
1

votes
3

answer
6.8k

Views

How can I make the text of checkbox wraps automatically with changing form width?

In windows forms I have checkbox list that contains long text, the form is re-sizable.. can I make the text wraps automatically in run-time according to the form width ?
Emad Khalil
0

votes
2

answer
41

Views

System.InvalidCastException: 'Unable to cast object

Trying to get the value of the selected object in a combobox (dropdown list) Getting this error: System.InvalidCastException: 'Unable to cast object of type 'System.Collections.Generic.KeyValuePair`2[System.String,schoolstuff.Employee]' to type 'schoolstuff.Employee'.' I tried to find a "Value" for...
Krystian
0

votes
0

answer
15

Views

Do a form event without open it

I have a form what I show with .ShowDialog method. new NewDesignForm() { ProjectKey = this.ProjectKey, ProjectGuid = this.ProjectGuid, DesignName = this.DesignParentName, DesignKey = this.DesignKey, isChangeOrder = this.IsChangeOrder }.ShowDialog(); This form have a button btnAdd who have an event....
Jonathan
0

votes
0

answer
7

Views

How to automatically classify the Outlook email sensitivity for Azure Information Protection in VB.Net?

I'm developing a windows from using vb.net, trying to send an email through outlook. My code is running fine, but once it reaches the send() line, a pop-up of Azure Information Protection to select the email sensitivity (Public, Confidential, ...etc), so the email will not be sent until a user selec...
Ahmed Mli
1

votes
2

answer
151

Views

c# copy from text file to word document

I want to copy data from text file to word file. I already have tried it with different alternatives like string array, StringBuilder and StreamReader using Interop which works good, but it takes too much time. It would really be thankful if anyone can suggest me with a better one. Been through many...
Ashish Srivastava

View additional questions