|
Hi Mridang,
First of all, please go through the msdn documents CheckBox.CheckedChanged[^]
It should fire. There is no bug in the .net, concerning this.
As I said in my previous post, check using again.
this.checkbox.Checked = !this.checkbox.Checked;
or
private void ChangeCheckBoxState(CheckBox cbx)
{
cbx.Checked = !cbx.Checked;
System.Diagnostics.Debug.WriteLine("checked state transformed to " + this.checkBox1.Checked);
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
MessageBox.Show("Check Changed");
}
You can explicitly also call the event handler, just to reconfirm as
this.checkBox1_CheckedChanged(this, new System.EventArgs());
I would also advice you to prepare a simple demo project to check the above phenomenon.
Regards,
Jay.
|
|
|
|
|
anyone knows how I can change the window class name of a winform?
now I get something like "WindowsForms10.Window.0.app4"
|
|
|
|
|
Override CreateParams in your derivative class and set the CreateParams.ClassName . If this is not an existing Window class, you'll need to P/Invoke RegisterClassEx and call it prior to creating any instances of your new control class. See http://pinvoke.net/default.aspx/user32.RegisterClassEx[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
I have a problem regarding events of form controls especially in the order in which they are raised on different operating systems.
For example:
I have LostFocus event for a ListView and GotFocus event for TextBox. When the user navigates from ListView to TextBox we are unable to determine the order in which these two events are fired. We noticed that in some operating systems LostFocus of ListView is raised first but in some other systems GotFocus of TextBox is raised first. This is an example to present the problem.
Can somebody help me out how to control this order on different OS/System? I want to raise the events in a same order though user uses my program on different machines so that I can program accordingly.
Thanks in advance.
Sundar
|
|
|
|
|
try using Validated and Enter events in place of LostFocus and GetFocus events respectively;
|
|
|
|
|
Hi! I'm a 14 year old programmer that has programmed in 4 other languages so far other than C#. I'm creating an IDE for one of the languages, and was wondering how I would go about doing syntax hilighting in a Rich Text Box. Sorry, please
explain it in a way a 14 year old half-newbie at C# could understand! Thanks in advance!
|
|
|
|
|
Akin to my last reply to the question below yours, this site contains hundreds of articles, but you need to search first. Research is just part of development.
Adding to that, the RichEdit control is not the best option. You get inundated in overriding the behavior of the control when defining your own edit control (or reusing an existing control available in third-party controls, either free or commercial) gives you far more capabilities. The RichEdit control itself isn't very flexible. To be more flexible you have to P/Invoke a whole slew of native functions and define several interfaces for interop. In both cases, your marshaling a lot of data between native and managed code. For this reason, I recommend you use Managed C++ for a mixed-mode assembly (containing both native and managed code). This will optimize the calls - especially in the upcoming release of Visual Studio 2005 (more specifically, Visual C++ 2005 using the /clr switch).
For more information about the RichEdit APIs and interfaces, read Rich Edit Controls[^] in the Platform SDK documentation.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I want to add a Column containing Command Buttons to ListView Control... is it even possible... can i have some sample code...
thanx in advance
|
|
|
|
|
This site contains hundreds of articles about many topics, including owner drawing the ListView control, but you need to search to find them.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm building a middleware program (client program) that receives data from a Sync Server (a hardware based device which pumps data to the network). The client program is suppose to:
1. Read all the data from the sync server.
2. Compare it to the formated data output (Hex value). If the data starts out as 0x08 then the client will be reading 9 bytes after that. If it shows 0x22 then the client will be reading 5 bytes instead.
The problem I have is the following:
1. How do I read from the Sync Server, when I know how the data format looks like but I have no control over the server side (since it simply pumps the data out to the network)?
2. Then if I'm reading the data in binary how do I convert that to Hex? Hex is easier to manipulate when I need to do a bitwise comparison.
The goal for now:
1. Get it to read the bits from the Sync Server
2. Print each bytes out individually and do some bitwise calculation on it to make sure that i can manipulate it.
Any help is very apprecieated
|
|
|
|
|
|
hello,
I would like to use xml file in multi-user enviroment.
Meaning, i need to allow adding lines to the xml.
my problem is that i don't know how to handle a situation when two users update the xml file at the same time. since the xml is re-written, the first changement will be lost.
so I need a way to prevent two or more access at the same time.
how to do so?
Eran.
|
|
|
|
|
You could use an object of FileStream class to access your XML-file, which provides some constructors that allow you to specify how the file will be shared by processes.
www.troschuetz.de
|
|
|
|
|
An XML file handle concurrency issues very poorly. Changes WILL be lost because you can only have one person writing to the file at any one time. Any writes MUST be done with an exclusive lock, since the entire XML file will be rewritten to the disk every time there is an update.
I would HIGHLY suggest moving the data to an actual SQL server, which is designed to handle concurrency... And I don't mean an Access database.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've run in to a very strange problem. When I insert a breakpoint in my C# application, the debugger hangs for about 10 seconds and then my form is dead (but not closed). Even the thread it is executing in is gone. If I run the code without any breakpoints, all is fine.
There is one other who has experienced the same problem, but I cannot find out if he solved it or not. You can find his post on "http://www.talkaboutsoftware.com/group/microsoft.public.vsnet.debugging/messages/8688.html".
Has any one else come across this before?
Thanks!
|
|
|
|
|
I am new to .NET in general and Windows Forms programming in particular. As a part of a bigger project, I am trying to write a test application.
I have a ListView control whose number of rows and columns are determined by the user at runtime. To read the number of rows and columns, I have provided two textboxes. I have a refresh button, which when clicked, reads the number of rows and columns from the text boxes and tries to populate the ListView control.
When I run the program and click on the Refresh button, it appears as if nothing has happened in response to that click. The fact, however, is that the ListView control gets populated successfully, but no data is visible because the columns somehow overlap each other. I verified this by clicking inside the ListView control and pressing "CTRL +". On doing that, the columns auto-arrange themselves and become visible.
My gut feeling is that this is something really simple and stupid. Please help me out!
========================= CODE BEGINS ===========================================================
<code>using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ListViewTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox TB_Rows;
private System.Windows.Forms.TextBox TB_Columns;
private System.Windows.Forms.Label LABEL_Rows;
private System.Windows.Forms.Button BTN_Refresh;
private System.Windows.Forms.ListView LV_Data;
private System.Windows.Forms.Label LABEL_Columns;
private System.Windows.Forms.TextBox TB_BaseString;
private System.Windows.Forms.Label LABEL_BaseString;
private int m_iColumnCount;
private int m_iRowCount;
private string m_szBaseString;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#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()
{
this.LV_Data = new System.Windows.Forms.ListView();
this.TB_Rows = new System.Windows.Forms.TextBox();
this.TB_Columns = new System.Windows.Forms.TextBox();
this.LABEL_Rows = new System.Windows.Forms.Label();
this.LABEL_Columns = new System.Windows.Forms.Label();
this.BTN_Refresh = new System.Windows.Forms.Button();
this.TB_BaseString = new System.Windows.Forms.TextBox();
this.LABEL_BaseString = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// LV_Data
//
this.LV_Data.Location = new System.Drawing.Point(16, 8);
this.LV_Data.Name = "LV_Data";
this.LV_Data.Size = new System.Drawing.Size(768, 248);
this.LV_Data.TabIndex = 0;
//
// TB_Rows
//
this.TB_Rows.Location = new System.Drawing.Point(52, 272);
this.TB_Rows.Name = "TB_Rows";
this.TB_Rows.Size = new System.Drawing.Size(96, 20);
this.TB_Rows.TabIndex = 1;
this.TB_Rows.Text = "5";
//
// TB_Columns
//
this.TB_Columns.Location = new System.Drawing.Point(227, 272);
this.TB_Columns.Name = "TB_Columns";
this.TB_Columns.Size = new System.Drawing.Size(96, 20);
this.TB_Columns.TabIndex = 2;
this.TB_Columns.Text = "8";
//
// LABEL_Rows
//
this.LABEL_Rows.Location = new System.Drawing.Point(13, 276);
this.LABEL_Rows.Name = "LABEL_Rows";
this.LABEL_Rows.Size = new System.Drawing.Size(40, 16);
this.LABEL_Rows.TabIndex = 3;
this.LABEL_Rows.Text = "Rows:";
//
// LABEL_Columns
//
this.LABEL_Columns.Location = new System.Drawing.Point(172, 274);
this.LABEL_Columns.Name = "LABEL_Columns";
this.LABEL_Columns.Size = new System.Drawing.Size(56, 16);
this.LABEL_Columns.TabIndex = 4;
this.LABEL_Columns.Text = "Columns:";
//
// BTN_Refresh
//
this.BTN_Refresh.Location = new System.Drawing.Point(680, 272);
this.BTN_Refresh.Name = "BTN_Refresh";
this.BTN_Refresh.Size = new System.Drawing.Size(104, 20);
this.BTN_Refresh.TabIndex = 5;
this.BTN_Refresh.Text = "Refresh";
this.BTN_Refresh.Click += new System.EventHandler(this.BTN_Refresh_Click);
//
// TB_BaseString
//
this.TB_BaseString.Location = new System.Drawing.Point(472, 272);
this.TB_BaseString.Name = "TB_BaseString";
this.TB_BaseString.Size = new System.Drawing.Size(168, 20);
this.TB_BaseString.TabIndex = 6;
this.TB_BaseString.Text = "Test";
//
// LABEL_BaseString
//
this.LABEL_BaseString.Location = new System.Drawing.Point(360, 275);
this.LABEL_BaseString.Name = "LABEL_BaseString";
this.LABEL_BaseString.Size = new System.Drawing.Size(104, 16);
this.LABEL_BaseString.TabIndex = 7;
this.LABEL_BaseString.Text = "Base String:";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(792, 405);
this.Controls.Add(this.LABEL_BaseString);
this.Controls.Add(this.TB_BaseString);
this.Controls.Add(this.BTN_Refresh);
this.Controls.Add(this.LABEL_Columns);
this.Controls.Add(this.LABEL_Rows);
this.Controls.Add(this.TB_Columns);
this.Controls.Add(this.TB_Rows);
this.Controls.Add(this.LV_Data);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Form1 form = new Form1 ();
Application.Run(form);
}
private void BTN_Refresh_Click(object sender, System.EventArgs e)
{
// Read the column count. This includes the "Item" column
this.m_iColumnCount = ReadColumnCount ();
// Read the row count. This includes the "Item" column
this.m_iRowCount = ReadRowCount ();
// Read the base string. Set it to "test" if it is empty
this.m_szBaseString = this.TB_BaseString.Text;
if (this.m_szBaseString.Length == 0)
this.m_szBaseString = "Test";
ClearListView ();
PopulateListView ();
}
/// <summary>
/// InitListView
/// </summary>
/// <param name="lv"></param>
/// <param name="bIsScrollable"></param>
private void InitListView (ListView lv, bool bIsScrollable)
{
lv.View = View.Details;
lv.GridLines = true;
}
/// <summary>
/// PopulateListView
/// </summary>
public void PopulateListView ()
{
InitListView (this.LV_Data, true);
// Create the columns
CreateColumns ();
// Create and populate the rows
ListViewItem[] listViewItemArray = null;
CreateListViewItems (out listViewItemArray);
//Add the items to the ListView.
this.LV_Data.Items.AddRange (listViewItemArray);
}
/// <summary>
/// CreateColumns
/// </summary>
private void CreateColumns ()
{
// Create the "Item" column first
//this.LV_Data.Columns.Add ("Item Column", -2, HorizontalAlignment.Left);
// Now create the data columns
for (int i=0; i < m_iColumnCount; i++)
this.LV_Data.Columns.Add ("Column " + i.ToString(), -2 * (i+1), HorizontalAlignment.Left);
}
/// <summary>
/// CreateListViewItems
/// </summary>
/// <param name="itemArray"></param>
private void CreateListViewItems (out ListViewItem[] itemArray)
{
itemArray = new ListViewItem[this.m_iRowCount];
for (int i=0; i < this.m_iRowCount; i++)
{
ListViewItem newItem = new ListViewItem (this.m_szBaseString + " " + i.ToString (), i);
AddSubItemsToListViewItem (i, newItem);
itemArray[i] = newItem;
}
}
/// <summary>
/// AddSubItemsToListViewItem
/// </summary>
/// <param name="iRowNumber"></param>
/// <param name="listViewItem"></param>
private void AddSubItemsToListViewItem (int iRowNumber, ListViewItem listViewItem)
{
for (int i=0; i < this.m_iColumnCount - 1; i++)
listViewItem.SubItems.Add (i.ToString());
}
/// <summary>
/// ClearListView ()
/// </summary>
private void ClearListView ()
{
this.LV_Data.Columns.Clear ();
this.LV_Data.Items.Clear ();
this.LV_Data.Clear ();
}
/// <summary>
/// ReadRowCount
/// </summary>
/// <returns></returns>
private int ReadRowCount ()
{
return ReadIntegerFromTextBox (this.TB_Rows, 15);
}
/// <summary>
/// ReadColumnCount
/// </summary>
/// <returns></returns>
private int ReadColumnCount ()
{
return ReadIntegerFromTextBox (this.TB_Columns, 10);
}
/// <summary>
/// ReadIntegerFromTextBox
/// </summary>
/// <param name="textBox"></param>
/// <param name="iDefaultValue"></param>
/// <returns></returns>
private int ReadIntegerFromTextBox (TextBox textBox, int iDefaultValue)
{
int iIntegerValue = iDefaultValue;
try
{
iIntegerValue = int.Parse (textBox.Text);
}
catch (FormatException)
{
iIntegerValue = iDefaultValue;
}
return iIntegerValue;
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}</code>
=========================== CODE ENDS ===========================================================
Thanks in advance,
-KMAnsari
|
|
|
|
|
private void CreateColumns ()
{
// Create the "Item" column first
//this.LV_Data.Columns.Add ("Item Column", -2, HorizontalAlignment.Left);
// Now create the data columns
for (int i=0; i < m_iColumnCount; i++)
this.LV_Data.Columns.Add ("Column " + i.ToString(), -2 * (i+1), HorizontalAlignment.Left);
}
ur setting the width of your columns to -2*(i+1) which will always be <0. I dont understand what ur trying to do here, but if u just change the width to a fixed one (70), everything works fine.
|
|
|
|
|
|
Hi all,
This is a simple question, but I haven't been able to find the answer in MSDN:
What does the ~ I have seen in some URLs mean? (such as "~/dwapp/default.aspx") I know what it means on a unix system - "your home directory" - but I haven't found the 1 line explanation I saw in *some* ASP book I've read.
Thanks in advance.
Frank Alviani
|
|
|
|
|
Simple - it means 'your home directory'. If you precede your URL with a ~, then it is absolute, and from the root of the application.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Some properties of ASP.NET controls (e.g. the ImageUrl property of e.g. the HyperLink control) expands this to the actual home directory.
In my own Page base class I use a similar function to acchieve the same. Here is an excerpt:
public class PageBase :
System.Web.UI.Page
{
public static string ReplaceTilde(
string path )
{
if ( path==null ||
path.Length==0 ||
path.IndexOf( '~' )!=0 )
{
return path;
}
else if ( HttpContext.Current==null ||
HttpContext.Current.Request==null )
{
string tilde = ConfigurationSettings.AppSettings["replaceTildeFallback"];
if ( tilde!=null && tilde.Length>0 )
{
tilde = tilde.TrimEnd( '\\', '/' );
return path.Replace( "~", tilde );
}
else
{
return path;
}
}
else
{
string tilde;
if ( HttpContext.Current.Request.ApplicationPath=="/" )
{
tilde = string.Empty;
}
else
{
tilde = HttpContext.Current.Request.ApplicationPath;
}
return path.Replace( "~", tilde );
}
}
} Maybe this is somehow useful to you.
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|
Hi,
Why does the code below run the method correctly, but then create this error:
"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
using System;<br />
using System.Collections.Generic;<br />
using System.Globalization;<br />
using System.Reflection;<br />
using System.Text;<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
Type t = typeof(Program);<br />
object[] argsg = new object[] { 100, 184 };<br />
MethodInfo teste= t.GetMethod("ComputeSum");<br />
teste.Invoke(null, BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.Static, null, argsg, CultureInfo.InvariantCulture);<br />
}<br />
public static void ComputeSum(int num1, int num2)<br />
{<br />
Console.WriteLine(num1 + num2);<br />
Console.ReadKey();<br />
return;<br />
}<br />
}<br />
}<br />
Thanks
|
|
|
|
|
|
I ran the code and I did not received that exception. What are you trying to do exactly?
~javier lozano
(blog)
|
|
|
|
|
I'm trying to invoke the static method ComputeSum using reflection, this example is to show my problem, but it is part of a larger project. I'm using VC#S 2005 beta + .net 2
Thanks
|
|
|
|
|