|
You write code code in the Click event handler of the buttons...
|
|
|
|
|
C# controls have a "Text" attribute. Assigning a string to this attribute will change the control's text. For example:
System.Windows.Forms.TextBox nextQuestion;
...
nextQuestion.Text = "What was the name of Paul McCartney's first band?"; or
System.Windows.Forms.Button nextAnswerButton;
...
nextAnswerButton.Text = "The Beatles";
|
|
|
|
|
so if my buttons name is "button1" so it will go something like this?
System.Windows.Forms.TextBox button1;
...
button1.Text = "What was the name of Paul McCartney's first band?";
|
|
|
|
|
|
but the question is how will the program know to which text to go?
i mean do i have to declare something or something like that or any other action?
thanks a lot!!!
|
|
|
|
|
Whatever string you assign to the text member will appear on the screen. It's your decision.
|
|
|
|
|
can you show me how i assign a string to a text please and in what section of the code i write it in?
thanks!!!!!!
|
|
|
|
|
You need to learn how to program in C#. There are many tutorials on the Web. They're free.
|
|
|
|
|
You need to dynamically create your choices based on the allowed choices. You can still use the same event listener if you utilize the Tag property in windows forms based applications, or in web forms based applications you will be able to use the ClientID property.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
what do you mean by "dynamically create your choices"?
|
|
|
|
|
It is possible to develop your user interface at run time without the benefit of using the Visual Designer. By doing so you will have complete control over the look, placement, actions, etc. of these buttons. Creating controls at runtime is called dynamic creation. There are many articles available that can shed a lot more detailed light on the subject than I can in a brief post.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
can please refer me to an article that can explain to me?
thanks!!!
|
|
|
|
|
Now, I'm use to data paging in DataGridView. When I search data on DataGridView that is just show data in present page. Have the way solve this problem? I would like get all data rows of DataTable that is being data paging on DataGridView.
For example: pagesize = 5, DataTable have two pages.
data in 1st page:
name age
John 21
N.John 20
Nancy 20
Tomath 21
Jan 22
and data in 2nd page:
name age
Jany 20
Alpha 21
Don 22
Bony 20
Tomy 22
One-page is present page. I'm beginning search data at "name" column as 'Tom'. It is just show one row in DataGridView. This data is correct when it show two rows in DataGridView. That is all. Can anyone help me?
modified on Wednesday, September 10, 2008 7:04 PM
|
|
|
|
|
Hi everybody.
How can I Abort all created Thread ?
For example :
I created a button that creates a thread by clicking on it.
Now I want close all of open Threads when my WinForm close.
|
|
|
|
|
When you create the threads, set the IsBackground property to true .
Then these threads are terminated when the app closes.
----------------------------------
Be excellent to each other
|
|
|
|
|
The threads belong to the process they were created from and cannot exist outside it. When the process is terminated, all it's threads are too.
|
|
|
|
|
I like to create member variables for the the class that contains the run method in my thread and then have a thread-safe method in said class that allows graceful termination of the run method.
If I have a form that closes I create an listener on the OnClosing event and then signal, or request from the threads to stop gracefully.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
HI
I'm using SetupApi dll and invoking SetupDiGetClassDevs Method to list all the devices of my computer, but i need to know the devices that are connected to the Serial port or the ports that contain the device and it name, it will help a lot for..
please do help me asap.
modified on Wednesday, September 10, 2008 7:18 AM
|
|
|
|
|
Where did you get that DLL? And what exactly are you trying to do?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
that is system dll, im invoking it...
this is code..
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
public static extern IntPtr RegisterDeviceNotification(IntPtr hRecipient, DEV_BROADCAST_DEVICEINTERFACE NotificationFilter, UInt32 Flags);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
public static extern uint UnregisterDeviceNotification(IntPtr hHandle);<br />
<br />
[DllImport("setupapi.dll", SetLastError = true)]<br />
public static extern IntPtr SetupDiGetClassDevs(ref Guid gClass, UInt32 iEnumerator, IntPtr hParent, UInt32 nFlags);
List< string > HWList = new List< string >();
public list< string > getAll()
{
Guid myGUID = System.Guid.Empty;
IntPtr hDevInfo = Native.SetupDiGetClassDevs(ref myGUID, 0, IntPtr.Zero, Native.DIGCF_ALLCLASSES | Native.DIGCF_PRESENT);
if (hDevInfo.ToInt32() == Native.INVALID_HANDLE_VALUE)
{
throw new Exception("Invalid Handle");
}
Native.SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData = new Native.SP_DEVINFO_DATA();
DeviceInfoData.cbSize = 28;
DeviceInfoData.devInst = 0;
DeviceInfoData.classGuid = System.Guid.Empty;
DeviceInfoData.reserved = 0;
UInt32 i;
StringBuilder DeviceName = new StringBuilder("");
DeviceName.Capacity = Native.MAX_DEV_LEN;
for (i = 0; Native.SetupDiEnumDeviceInfo(hDevInfo, i, DeviceInfoData); i++)
{
while (!Native.SetupDiGetDeviceRegistryProperty(hDevInfo,
DeviceInfoData,
Native.SPDRP_DEVICEDESC,
0,
DeviceName,
Native.MAX_DEV_LEN,
IntPtr.Zero))
{
}
HWList.Add(DeviceName.ToString());
}
}
In the HWList Array all the devices are listed, but i need to check which device is connected to serial port(may be is it possible to do with the Device ID)
|
|
|
|
|
that you've been asking for several days now?
Blog link to be reinstated at a later date.
|
|
|
|
|
hi,I'm trying to get the CPU id and encryp it with rsa, the problem is : i have an application in a deferent pc, i want the application show the cpu id to the user, and the user use a telephone (not internet) to ask the activation key.i know haw to get the cpu id, but i dont know how to use RSA in c#, because i need to encrypt and sign the id and show it in textbox, then i read it for user and user enter the activation key in the application and the application decrypt and validate it.
THANKS
ajgm
|
|
|
|
|
If I understand you correctly, you probably just need System.Security.Cryptography.RSACryptoServiceProvider .
|
|
|
|
|
thanks for your help it was so usefull
ajgm
|
|
|
|
|
I Use following code for Excel to List view entry
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
ExcelObj = new Excel.Application();
if (ExcelObj == null)
{
MessageBox.Show("ERROR: EXCEL couldn't be started!");
System.Windows.Forms.Application.Exit();
}
object val = new object();
ExcelObj.Visible = true;
}
string[] ConvertToStringArray(System.Array values)
{
string[] theArray = new string[values.Length];
for (int i = 1; i <= values.Length; i++)
{
if (values.GetValue(1, i) == null)
theArray[i-1] = "";
else
theArray[i-1] = (string)values.GetValue(1, i).ToString();
}
return theArray;
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5,
this.columnHeader6,
this.columnHeader7,
this.columnHeader8,
this.columnHeader9,
this.columnHeader10});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(26, 43);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(536, 240);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "LastName";
this.columnHeader1.Width = 98;
//
// columnHeader2
//
this.columnHeader2.Text = "FirstName";
this.columnHeader2.Width = 93;
//
// columnHeader3
//
this.columnHeader3.Text = "Company";
this.columnHeader3.Width = 83;
//
// columnHeader4
//
this.columnHeader4.Text = "Address";
this.columnHeader4.Width = 73;
//
// columnHeader5
//
this.columnHeader5.Text = "City";
this.columnHeader5.Width = 71;
//
// columnHeader6
//
this.columnHeader6.Text = "State";
this.columnHeader6.Width = 67;
//
// columnHeader7
//
this.columnHeader7.Text = "Zip";
//
// columnHeader8
//
this.columnHeader8.Text = "Country";
//
// columnHeader9
//
this.columnHeader9.Text = "E-mail";
//
// columnHeader10
//
this.columnHeader10.Text = "Phone";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Open...";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// openFileDialog1
//
this.openFileDialog1.DefaultExt = "*.xls";
this.openFileDialog1.Filter = "Excel File (*.xls) | All Files (*.*) ||";
this.openFileDialog1.Title = "Choose an Excel File";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(584, 341);
this.Controls.Add(this.listView1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Reading an Excel Spreadsheet";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
this.openFileDialog1.FileName = "*.xls";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Excel.Workbook theWorkbook =
ExcelObj.Workbooks.Open(
openFileDialog1.FileName, 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
// get the collection of sheets in the workbook
Excel.Sheets sheets = theWorkbook.Worksheets;
// get the first and only worksheet from the collection
// of worksheets
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
for (int i = 1; i <= 10; i++)
{
Excel.Range range = worksheet.get_Range("A"+i.ToString(), "J" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
listView1.Items.Add(new ListViewItem(strArray));
}
}
}
}
}
ERROR:
Error 1 No overload for method 'Open' takes '13' arguments
Error 2 Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Excel.Range.get_Value(object)' or 'Excel.Range.set_Value(object, object)
Can Any One Give Me Solution Please
|
|
|
|
|