VB6 Button.Value = true/false - how to do this in c#?

  • Thread starter Thread starter Chua Wen Ching
  • Start date Start date
C

Chua Wen Ching

Hi there,

button1.Value = true/false 'in vb6

how to code that in c#? Any help please?

I cannot find the value properly for buttons in c#. I not
sure what to replace value for buttons?

Thanks.

Regards,
Chua Wen Ching
 
Piece of cake. Use the following code and create a new WinForms control
with it. This class inherits from the System.Windows.Forms.Button control
and adds a Value property. You can then use this new "Value Button" on your
forms rather than the standard button and store a value in it. Feel free to
modify the "imports" as needed - I removed some of the properties you
shouldn't need (I currently generate this buttons at runtime in a POS
application and add product ID's to the value members so I can determine
what product was clicked and then retrieve price information from the
database.)

Brian Patterson
NOTE: Remove upper case characters from email address to email me directly.
----------------------------------<snip>------------------------------------
-
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace ValueButton
{

public class ValueButton : System.Windows.Forms.Button
{

private int m_Value;

private System.ComponentModel.Container components = null;

public ValueButton()
{

InitializeComponent();



}


protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
public int Value
{
get
{
return m_Value;
}
set
{
m_Value=value;
}
}





#region Component 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()
{
//
// ValueButton
//
this.Name = "ValueButton";

}
#endregion
}
}
----------------------------------<snip>------------------------------------
-
 
Chua said:
Hi there,

button1.Value = true/false 'in vb6

how to code that in c#? Any help please?

I cannot find the value properly for buttons in c#. I not
sure what to replace value for buttons?

How about using the .Tag property?
 
Dude, from the looks of things here it might be best for you to go out and
buy a book on C#.
 
Back
Top