|
Thanks for your help Mr.Giorgi Dalakishvili,
But that won't solve my Problem,
See, I am not using MDI.
I have Main Form which contains Exit,Form1 and few other buttons, and my functionality to close the application is written in exit button.
But when user clicks any other button say,Form1 to go Form1, Since The Main Forms Close event also calling at that time the Main Form too closing not my application(So all the threads and timers that I wrote in exit button are not ending)
I just want to know how to call my exit button functinality Only when user clicks ControlBox's X Button.
Thanks,For ur Time
Pashi
|
|
|
|
|
Your post is quite unclear but from what I guess that when you click Form1, your main form is closing. Why do you do that? Just show Form1.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks Again For your reply,
say I am in Main Form Now.
After I click on Form1 Button of Main Form, Main Form's Closing event is calling and since the in the ControlBox 'X' Button is also calling Main Form's Closing event for Main form the application is closing.
So, I just want to know do I have any alternate so that, I can catch the form Closing Event
I mean whether the process is entering into form closing event by ControlBox's 'X' click or
while redirecting to any other form.
Hope you got my point now!
Thanks again for ur time
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Maybe a CloseReason property of a FormClosingEventArgs object which passed by a Closing event is what are you looking for.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
The pages have been done with a 1280 x 1024 resolution. I am currently using it on a laptop having 1440 x 900, and unfortunately I can not reach the previous next button placed on the bottom of the page without scrolling down each time.
Is there any way, that i can set the properties of form such that it will make the form size as per windows pixel values.
|
|
|
|
|
The dock and anchor properties can be set to make a form resize itself cleanly.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
yes you r right that dock property is being use to resizing the control, but i m currently using the FORM not controls, my form is not getting resized accordingly and form is not having any dock property.
and i have made autosize property of form to grow and shrink.
can you guide me for this.
Thanks
|
|
|
|
|
Hi,
you can set your Form's Size at Load time using your monitor's Size; have a look at
either the Screen class or SystemInformation.PrimaryMonitorSize
|
|
|
|
|
I'm having intermitent problems with my winforms app since I added a System.IO.Ports.SerialPort object to receive strings from the serial port, then write those strings to the database.
I know that because of cross-threading exceptions, if I want to update any control on my form, I need to update it from that control's invoke method. I'm fine with that.
But what if I want to execute a method of an object that doesn't inherit from Windows.Forms.Control, and therefore doesn't have an Invoke method?
For example
DataAccessLayer dal;
IO.Ports.SerialPort port;
string portBuffer;
private void frmMain_Load(object sender, EventArgs e)
{
dal = new DataAccessLayer();
port = new IO.Ports.SerialPort();
}
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
portBuffer += port.ReadExisting();
if (portBuffer.Contains("OK"))
dal.InsertStringIntoDatabase(portBuffer);
}
Does the 'dal' object run on a different thread from the 'port' object? If so, must I write a custom BeginInvoke, Invoke method for the 'dal' object. The dal object does not inherit from Control.
Thanks
|
|
|
|
|
This should work just fine. I have threads sharing objects that are non UI all the time,
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I may be wrong, I don't do a lot of thread work however as you are declaring the dal and port objects in the main thread where is the additional thread involved.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I want to store subscript and superscript like H20, H2SO4, 6th in sql server and also vb.net windows application also..
i'm using vb.net2005 ..
Please help me.........
Bye
K.Mani
kanmani84@gmail.com
By
K.mani
|
|
|
|
|
You asked the same question just yesterday and also in VB.NET forum.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi everybody,
I have DataGridView with notes and I need filtering but I dont know how I can filtering datagridview with bindingsource(object binding).
My code looks like this:
public class Note
{
public string Name {get;set;}
}
Form_load()
{
noteBindingSource.Filter = "Name = 'Jack'";
noteBindingSource.DataSource = NoteList.GetNoteList();
myDataGridView.DataSource = noteBindingSource;
}
But this isnt working. Result is all rows. I think "Filter" is unused.
Thanks for help
Bye
Marek
|
|
|
|
|
Try swapping the data source filter and assignment. You may be applying a filter to a binding source that has nothing in it.
Alteratively if GetNoteList is a table then you can use a filtered dataview (this is the option we use all the time)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am looking for help on how to speed up VB.NET (or C#) screen refresh speed.
I am in charge of writing a newer fancier user interface in .NET for an older legacy program. Because this needs to run on slow legacy machines I did a performance test and discovered the screen refresh speeds of VB6 is faster then .NET.
To do a head to head comparison I put together equivalent VB6 and VB.NET programs, each with a maximized form and 48 labels. Clicking on any label changes the background color of all the labels on the form. In VB6 there is barely a flicker as the colors change across the entire form all at once. In VB.NET you can see the color change moving across the form like a wave. To really see the problem it is best to try the following code on a slower machine (1GHz etc.)
In VB6 create a project MyProject and add a form MyForm with the following properties
Caption = "Screen Refresh test VB6"
BackColor = Black
WindowState = Maximized
On that form add a label MyLabel with the following properties:
Index = 0
Caption = "Hello World"
BackColor = Cyan
In the form add the following code:
Option Explicit
Const ROWS As Integer = 8
Const COLS As Integer = 6
Const PAD As Integer = 75 ' 5 pixels at 15 twips per pixel
Private colors(0 To 2) As Long
Private color As Integer
Private Sub Form_Load()
Dim index As Integer
colors(0) = vbCyan
colors(1) = vbYellow
colors(2) = vbGreen
For index = 1 To ROWS * COLS - 1
Call Load(MyLabel(index))
MyLabel(index).Caption = MyLabel(index).Caption & " " & CStr(index)
MyLabel(index).Visible = True
Next index
MyLabel(0).Caption = MyLabel(0).Caption & " 0"
End Sub
Private Sub Form_Resize()
Dim width As Single
Dim height As Single
Dim row As Integer
Dim col As Integer
Dim index As Integer
width = (Me.width - 60 - PAD * (COLS + 1)) \ COLS
height = (Me.height - 450 - PAD * (ROWS + 1)) \ ROWS
For col = 0 To COLS - 1
For row = 0 To ROWS - 1
index = col * ROWS + row
Call MyLabel(index).Move(PAD + col * (width + PAD), PAD + row * (height + PAD), width, height)
Next row
Next col
End Sub
Private Sub MyLabel_Click(index As Integer)
color = (color + 1) Mod 3
For index = 0 To ROWS * COLS - 1
MyLabel(index).BackColor = colors(color)
Next index
End Sub
The VB.NET program is virtually identical. Just create a windows project and past in the following code. This code defines a form and is self sufficient. It does not need the auto generated form code.
Public Class MyForm
Inherits System.Windows.Forms.Form
Private Const _ROWS As Integer = 8
Private Const _COLS As Integer = 6
Private Const _PAD As Integer = 5
Private _myLabel(_ROWS * _COLS - 1) As System.Windows.Forms.Label
Private _colors() As System.Drawing.Color = {Color.Cyan, Color.Magenta, Color.Yellow}
Private _color As Integer
Public Sub New()
Me.SuspendLayout()
For index As Integer = 0 To _ROWS * _COLS - 1
Me._myLabel(index) = New System.Windows.Forms.Label
Me._myLabel(index).BackColor = System.Drawing.Color.Cyan
Me._myLabel(index).Name = "MyLabel" & CStr(index)
Me._myLabel(index).TabIndex = index
Me._myLabel(index).Text = "Hello World " & CStr(index)
Me._myLabel(index).TextAlign = System.Drawing.ContentAlignment.MiddleCenter
AddHandler Me._myLabel(index).Click, AddressOf MyLabel_Click
Me.Controls.Add(Me._myLabel(index))
Next
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = FormStartPosition.CenterScreen
Me.WindowState = FormWindowState.Maximized
Me.BackColor = Color.Black
Me.Name = "MyForm"
Me.Text = "Screen Refresh Test VB.NET"
Me.ResumeLayout(False)
End Sub
Private Sub MyForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Dim resize As System.Drawing.Size = _
New System.Drawing.Size _
( _
(Me.ClientRectangle.Width - (_PAD * _COLS + 1)) \ _COLS, _
(Me.ClientRectangle.Height - (_PAD * _ROWS + 1)) \ _ROWS _
)
Me.SuspendLayout()
For col As Integer = 0 To _COLS - 1
For row As Integer = 0 To _ROWS - 1
With Me._myLabel(col * _ROWS + row)
.Size = resize
.Location = New System.Drawing.Point(_PAD + col * (.Width + _PAD), _PAD + row * (.Height + _PAD))
End With
Next
Next
Me.ResumeLayout()
End Sub
Private Sub MyLabel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
_color = (_color + 1) Mod _colors.Length
For index As Integer = 0 To _ROWS * _COLS - 1
Me._myLabel(index).BackColor = _colors(_color)
Next
End Sub
End Class
Any help or ideas would be appreciated. If there is a known solution please point me in the right direction.
|
|
|
|
|
Devan_Monroe wrote: I am in charge of writing a newer fancier user interface in .NET for an older legacy program.
Devan_Monroe wrote: each with a maximized form and 48 labels. Clicking on any label changes the background color of all the labels on the form.
So where is the "newer fancier user interface"? I mean if you are going to do the same garbage why bother rewriting?
led mike
|
|
|
|
|
This isn't the fancier interface. The code is there just to demonstrate that .NET is slower (as written). If there is any way to update the screen more quickly I'd love to hear about it.
|
|
|
|
|
Devan_Monroe wrote: If there is any way to update the screen more quickly I'd love to hear about it.
Ok. Using the newer fancier user interface approaches it will be way faster.
Does that help?
led mike
|
|
|
|
|
Well, double buffering would help, and; oh yes, it's standard with .NET.
|
|
|
|
|
I'll look into double buffering. If anyone else has ideas or suggestions please chime in.
Oh, and by "it's standard with .NET" do you mean that this is well known and people are just putting up with it? 
|
|
|
|
|
I am still looking for a way to refresh multiple controls on the screen at the same time.
I have tried using double buffering. This works well for a single control that uses various graphics drawing methods. But sub-controls still refresh on the screen independently of each other and their container.
I have tried using WM_SETREDRAW windows message to turn off and back on updating of a control. This requires an invalidate or refresh afterward. The redrawing of the control and sub-controls still occur independently of each other.
Has anyone found any way to make a form and all of its sub-controls update on the screen at the same time? Any help is greatly appreciated.
|
|
|
|
|
Hi
I am populating a List<lisviewitem>. When i add this list to ListView it generates error. Sample is below:
List<listviewitem> lstItems = new List<listviewitem>();
ListViewItem item = null;
listView1.Items.Clear();
listView2.Items.Clear();
listView1.BeginUpdate();
listView2.BeginUpdate();
item = new ListViewItem("<<All>>");
item.Tag = 0;
lstItems.Add(item);
item = null;
for (int i = 0; i < DS.Tables["Table"].Rows.Count; i++)
{
item = new ListViewItem(DS.Tables["Table"].Rows[i]["Column1"].ToString());
item.Tag = DS.Tables["Table"].Rows[i]["Column2"];
lstItems.Add(item);
item = null;
}
listView1.Items.AddRange(lstItems.ToArray());
listView1.EndUpdate();
listView2.Items.AddRange(lstItems.ToArray());
listView2.EndUpdate();
listView1.Items[0].Checked = true;
listView2.Items[0].Checked = true;
lstItems = null;
Can anybody provide a better solution for this.
|
|
|
|
|
Welcome to CodeProject
You need to read the posting instruction for posting code like HTML, XML and Generics because they all use the '<' and '>' characters which require special handling since this forum is a Web based forum and therefore uses HTML which is a tag based language.
Also you can say things like:
Member 3875850 wrote: it generates error
You should post the exact error message and any other relevant information.
led mike
|
|
|
|
|
I want to store subscript and superscript like H20, H2SO4, 6th in sql server and also vb.net windows application also..
i'm using vb.net2005 ..
Please help me......... its urgent.
Bye
K.Mani
kanmani84@gmail.com
By
K.mani
|
|
|
|