Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
GeneralRe: Progress Bar as Notify Icon Pin
Ron Nicholson6-Mar-15 8:38
professionalRon Nicholson6-Mar-15 8:38 
GeneralRe: Progress Bar as Notify Icon Pin
Member 108502536-Mar-15 13:48
Member 108502536-Mar-15 13:48 
AnswerRe: Progress Bar as Notify Icon Pin
Ron Nicholson6-Mar-15 6:43
professionalRon Nicholson6-Mar-15 6:43 
QuestionVery Strange Behaviour (for me) ...... Pin
Emanuele Bonin5-Mar-15 22:06
Emanuele Bonin5-Mar-15 22:06 
AnswerRe: Very Strange Behaviour (for me) ...... Pin
Richard MacCutchan5-Mar-15 23:13
mveRichard MacCutchan5-Mar-15 23:13 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Emanuele Bonin6-Mar-15 2:53
Emanuele Bonin6-Mar-15 2:53 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Richard MacCutchan6-Mar-15 3:02
mveRichard MacCutchan6-Mar-15 3:02 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Emanuele Bonin6-Mar-15 7:10
Emanuele Bonin6-Mar-15 7:10 
I'm not an expert and could be that i wrote something wrong.
This behaiour is very strange and the code is not complicated.
So i try to post below the complete code part to reproduce the problem.
What is wrong in my code ?

Is Wrong to create a form on the fly (local variable) pass to it a textbox so called it with Show() instead of ShowModal() ? This type of code is not acceppted to the garbage collector ?
Or there is some other problem ?

The below code is completed so is possible to reproduce the problem double cliccking on textbox and selecting a date.



using System;
using System.Windows.Forms;
using System.Drawing;

namespace TestDataPicker
{
internal sealed class Program
{
[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}

}
public class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
void TextBox1DoubleClick(object sender, EventArgs e)
{
TextBox sd = sender as TextBox;
txtBaseDatePicker DP = new txtBaseDatePicker(sd);
DP.Location = sd.PointToScreen(Point.Empty + (Size)new Point(0, sd.Height));
DP.Show();
}

private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.TextBox textBox1;

protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(40, 54);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(144, 20);
this.textBox1.TabIndex = 0;
this.textBox1.DoubleClick += new System.EventHandler(this.TextBox1DoubleClick);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.textBox1);
this.Name = "MainForm";
this.Text = "testdatapicker";
this.ResumeLayout(false);
this.PerformLayout();

}

}
public partial class txtBaseDatePicker : Form
{
private TextBox txtDate;
public txtBaseDatePicker(TextBox TB):this(){
txtDate = TB;
}
public txtBaseDatePicker(){
InitializeComponent();
}

void CalDateSelected(object sender, DateRangeEventArgs e){
MonthCalendar s = (MonthCalendar) sender;

this.txtDate.Text = s.SelectionStart.ToString().Substring(0,10);
/////////////////////////////////////////////////////////////////////////////////////////////////////
///// STRANGE BEHAVIOURS ///////////
//
//this.CloseForm.Enabled = true; // Enabling timer 200 millisecond that close form all OK!

// eliminating one messaebox raise an exception
MessageBox.Show("1"); // this message will be supressede
MessageBox.Show("2");
this.Close(); // <-- This raise an exception
///////////////////////////////////////////////////////////////////////////////////////////////////
}

void TxtBaseDatePickerDeactivate(object sender, EventArgs e){
this.Close();
}
void CloseFormTick(object sender, EventArgs e)
{
this.CloseForm.Enabled = false;
this.Close();
}
///
/// Designer variable used to keep track of non-visual components.
///

private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.MonthCalendar cal;
private System.Windows.Forms.Timer CloseForm;


protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.cal = new System.Windows.Forms.MonthCalendar();
this.CloseForm = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
this.cal.Location = new System.Drawing.Point(4, 2);
this.cal.Name = "cal";
this.cal.TabIndex = 0;
this.cal.DateChanged += new System.Windows.Forms.DateRangeEventHandler(this.CalDateSelected);
this.CloseForm.Interval = 200;
this.CloseForm.Tick += new System.EventHandler(this.CloseFormTick);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.ClientSize = new System.Drawing.Size(232, 169);
this.ControlBox = false;
this.Controls.Add(this.cal);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "txtBaseDatePicker";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Deactivate += new System.EventHandler(this.TxtBaseDatePickerDeactivate);
this.ResumeLayout(false);
}

}




}
AnswerRe: Very Strange Behaviour (for me) ...... Pin
manchanx6-Mar-15 3:22
professionalmanchanx6-Mar-15 3:22 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Emanuele Bonin6-Mar-15 7:36
Emanuele Bonin6-Mar-15 7:36 
AnswerRe: Very Strange Behaviour (for me) ...... Pin
BillWoodruff6-Mar-15 4:51
professionalBillWoodruff6-Mar-15 4:51 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Emanuele Bonin6-Mar-15 7:29
Emanuele Bonin6-Mar-15 7:29 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
BillWoodruff6-Mar-15 13:20
professionalBillWoodruff6-Mar-15 13:20 
GeneralRe: Very Strange Behaviour (for me) ...... Pin
Emanuele Bonin6-Mar-15 20:57
Emanuele Bonin6-Mar-15 20:57 
QuestionGF(256) Multiplication Pin
Member 115029285-Mar-15 20:50
Member 115029285-Mar-15 20:50 
AnswerRe: GF(256) Multiplication Pin
Richard MacCutchan5-Mar-15 21:08
mveRichard MacCutchan5-Mar-15 21:08 
GeneralRe: GF(256) Multiplication Pin
harold aptroot5-Mar-15 23:12
harold aptroot5-Mar-15 23:12 
GeneralRe: GF(256) Multiplication Pin
Richard MacCutchan5-Mar-15 23:56
mveRichard MacCutchan5-Mar-15 23:56 
GeneralRe: GF(256) Multiplication Pin
harold aptroot6-Mar-15 0:04
harold aptroot6-Mar-15 0:04 
GeneralRe: GF(256) Multiplication Pin
Richard MacCutchan6-Mar-15 0:15
mveRichard MacCutchan6-Mar-15 0:15 
GeneralRe: GF(256) Multiplication Pin
harold aptroot6-Mar-15 0:21
harold aptroot6-Mar-15 0:21 
AnswerRe: GF(256) Multiplication Pin
harold aptroot6-Mar-15 0:24
harold aptroot6-Mar-15 0:24 
QuestionNeed Function to Redact SSNs and CCs from a string Pin
AnneThorne5-Mar-15 10:26
AnneThorne5-Mar-15 10:26 
SuggestionRe: Need Function to Redact SSNs and CCs from a string Pin
ZurdoDev5-Mar-15 10:43
professionalZurdoDev5-Mar-15 10:43 
GeneralRe: Need Function to Redact SSNs and CCs from a string Pin
AnneThorne5-Mar-15 10:56
AnneThorne5-Mar-15 10:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.