|
|
Hello,,
Is it possible to send a parameter like below?
CheckBox oCheckBox = new CheckBox();
oCheckBox.Name = "cb_" + currentChild.ID;
oCheckBox.Click += new RoutedEventHandler(this.CheckClick);
Now I want to send the name of check box to the event handler. HOw can I do it?
Like
CheckBox oCheckBox = new CheckBox();
oCheckBox.Name = "cb_" + currentChild.ID;
oCheckBox.Click += new RoutedEventHandler(this.CheckClick,oCheckBox.Name);
so that in
CheckClick(object sender, RoutedEventArgs e) I can get the name of that check box as there will be many dynamically created check box.
|
|
|
|
|
One of the following lines should work, with the caveat that I'm a little rusty on WPF, so apologies if my answer isn't correct!
CheckClick(object sender, RoutedEventArgs e)
{
CheckBox checkBox1 = (CheckBox)sender;
sring id = checkBox1.Name;
CheckBox checkBox2 = (CheckBox)e.OriginalSource;
sring id = checkBox2.Name;
}
|
|
|
|
|
|
Just try with this.
CheckClick(object sender, RoutedEventArgs e)
{
string chkBoxName = ((CheckBox)sender).Name;
}
|
|
|
|
|
|
Hi all,
Is there any way to track the GMAIL input values, while COMPOSSING the Mail.
i am trying like bellow but i could not get:
void browser_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
browser = (SHDocVw.InternetExplorer)pDisp;
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)browser.Document;
document = (HTMLDocument)doc;
IHTMLElementCollection elcol;
elcol = document.getElementsByTagName("iframe");
foreach (IHTMLElement ielcol in elcol)
{
HTMLIFrame frm = (HTMLIFrame)ielcol;
DispHTMLDocument docfrm = (DispHTMLDocument)((SHDocVw.IWebBrowser2)frm).Document;
IHTMLElementCollection elcolin = docfrm.all;
foreach (IHTMLElement iel in elcolin)
{
if (iel != null)
{
CreateLog(sLogPath, "IHTMLElement" + ":::" + iel.outerText + ":" +iel.outerHTML);
CreateLog(sLogPath, "\r\n -----------------------------------\r\n");
switch (iel.ToString())
{
case "mshtml.HTMLTextAreaElementClass":
mshtml.HTMLTextAreaElementClass tae = (mshtml.HTMLTextAreaElementClass)iel;
if (tae != null)
{
CreateLog(sLogPath, "HTMLTextAreaElementClass" + ":::" + tae.type + ":" + tae.value);
CreateLog(sLogPath, "\r\n -----------------------------------\r\n");
}
break;
}
}
}
}
}
i am trying to take To,CC,BCC,Subject values while sending mail,
Can some one suggest me how to go with...
thanks in advance
|
|
|
|
|
I am creating a mp3 player through C#.Net I have kept a CheckBox that shows the play list. I have created the player such that it when ever the user cicks on the selection on checkbox the player play the corresponding song. so the user has to click on the next song to play the next song once the previous song is finished.
Now I would like to know is it possible for the player to automatically play the next song once the previous song is finished? If so how do I go about doing this on C#.Net
Please let me know... Thanks!
|
|
|
|
|
Hi All,
I have a TextBox txtBx, I set text to it as-
txtBx.Text = "brutas\n\nhong\t\nsaw";
now on the application, raw characters(square boxes) are shown in stead of \n, \r etc.
I want the display in the textbox as
brutas hong saw
can any one help me?
|
|
|
|
|
You could use a Regex:
string s = "brutas\n\nhong\t\nsaw";
Regex r = new Regex("[\n\r\t]");
string t = r.Replace(s, " ");
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I am using a program to insert values in a table in an SQLEXPRESS database. My program tells me that the queries are being executed but when I check on the Database Explorer in Microsoft Visual Studio 2005, I do not see the values.
Kunle
|
|
|
|
|
Run the SQL Profiler and see what query is actually getting run on the database. This might help you find the problem.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
do you have empty catch{} blocks ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Try to use Stored Procedures and verify it
|
|
|
|
|
you have read just inserting code on particular event
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace HotelProject
{
public partial class NewEmployee : Form
{
SqlConnection con;
SqlCommandBuilder cmdb;
SqlDataAdapter da;
DataSet ds;
public NewEmployee()
{
con = new SqlConnection("Data source=JBB-F906306D8CC\\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=SSPI");
InitializeComponent();
}
private void btnBrowseImagePath_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
txtBrowseImagePath.Text = op.FileName;
}
}
private void btnSubmitRecord_Click(object sender, EventArgs e)
{
con.Open();
da = new SqlDataAdapter("Select * From EmployeeDetails", con);
cmdb = new SqlCommandBuilder(da);
ds = new DataSet("EmployeeDetails");
if (txtBrowseImagePath.Text != "")
{
FileStream fs = new FileStream(txtBrowseImagePath.Text, FileMode.OpenOrCreate, FileAccess.Read);
byte[] rawdata = new byte[fs.Length];
fs.Read(rawdata, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds, "EmployeeDetails");
DataRow dr = ds.Tables["EmployeeDetails"].NewRow();
dr["FullName"] = txtFullName.Text;
dr["FatherName"] = txtFatherName.Text;
dr["DateOfBirth"] = maskedTxtDateofBirth.Text;
dr["Gender"] = cmbgender.SelectedItem.ToString();
dr["Address"] = txtAddress.Text;
dr["City"] = txtCity.Text;
dr["Country"] = cmbCountry.SelectedItem.ToString();
dr["PhoneNo"] = txtPhone.Text;
dr["EMailID"] = txtEMailId.Text;
dr["LicenceNo"] = txtLicence.Text;
dr["EmployeeHotelId"] = txtEhotelid.Text;
dr["DepartmentName"] = cmbDepartmentName.SelectedItem.ToString();
dr["Designation"] = cmbDesignation.SelectedItem.ToString();
dr["Qualification"] = cmbQualification.SelectedItem.ToString();
dr["SalaryPerMonth"] = txtSalary.Text;
dr["HireDate"] = maskedtxtHireDate.Text;
dr["UserName"] = txtUserName.Text;
dr["Password"] = txtPassword.Text;
dr["Picture"] = rawdata;
ds.Tables["EmployeeDetails"].Rows.Add(dr);
da.Update(ds, "EmployeeDetails");
con.Close();
MessageBox.Show("Inserted");
}
else
{
MessageBox.Show("Not Inserted");
}
}
private void btnReset_Click(object sender, EventArgs e)
{
txtFullName.Text = "";
txtFatherName.Text= "";
maskedTxtDateofBirth.Text= "";
cmbgender.Text= "";
txtAddress.Text= "";
txtCity.Text= "";
cmbCountry.Text= "";
txtPhone.Text= "";
txtEMailId.Text = "";
txtLicence.Text = "";
txtEhotelid.Text= "";
cmbDepartmentName.Text= "";
cmbDesignation.Text = "";
cmbQualification.Text = "";
txtSalary.Text= "";
maskedtxtHireDate.Text= "";
txtUserName.Text= "";
txtPassword.Text= "";
txtBrowseImagePath.Text = "";
}
private void btnUpdate_Click(object sender, EventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void NewEmployee_Load(object sender, EventArgs e)
{
txtBrowseImagePath.Enabled = false;
txtFullName.Focus();
}
private void txtFullName_Validating(object sender, CancelEventArgs e)
{
if (txtFullName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtFullName.Focus();
}
else
{
txtFatherName.Focus();
}
}
private void txtFullName_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtFullName.Text = "";
}
}
private void txtFatherName_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtFatherName.Text = "";
}
}
private void txtFatherName_Validating(object sender, CancelEventArgs e)
{
if (txtFatherName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtFatherName.Focus();
}
else
{
maskedTxtDateofBirth.Focus();
}
}
private void maskedTxtDateofBirth_Validating(object sender, CancelEventArgs e)
{
if (maskedTxtDateofBirth.Text == "")
{
MessageBox.Show("You cannot leave it blank");
maskedTxtDateofBirth.Focus();
}
else
{
cmbgender.Focus();
}
}
private void cmbgender_Validating(object sender, CancelEventArgs e)
{
if (cmbgender.SelectedItem==null)
{
MessageBox.Show("You cannot leave it blank");
cmbgender.Focus();
}
else
{
txtAddress.Focus();
}
}
private void txtAddress_Validating(object sender, CancelEventArgs e)
{
if (txtAddress.Text=="")
{
MessageBox.Show("You cannot leave it blank");
txtAddress.Focus();
}
else
{
txtCity.Focus();
}
}
private void txtCity_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) == true)
{
MessageBox.Show("Insert character only");
txtCity.Focus();
}
}
private void txtCity_Validating(object sender, CancelEventArgs e)
{
if (txtCity.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtCity.Focus();
}
else
{
cmbCountry.Focus();
}
}
private void cmbCountry_Validating(object sender, CancelEventArgs e)
{
if (cmbCountry.SelectedItem==null)
{
MessageBox.Show("You cannot leave it blank");
cmbCountry.Focus();
}
else
{
txtPhone.Focus();
}
}
private void txtPhone_Validating(object sender, CancelEventArgs e)
{
if (txtPhone.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtPhone.Focus();
}
else
{
txtEMailId.Focus();
}
}
private void txtPhone_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show("Insert Integer only");
txtPhone.Focus();
}
}
private void txtEMailId_Validating(object sender, CancelEventArgs e)
{
if (txtEMailId.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtEMailId.Focus();
}
else
{
txtLicence.Focus();
}
}
private void txtLicence_Validating(object sender, CancelEventArgs e)
{
if (txtLicence.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtLicence.Focus();
}
else
{
txtEhotelid.Focus();
}
}
private void txtEhotelid_Validating(object sender, CancelEventArgs e)
{
cmbDepartmentName.Focus();
}
private void cmbDepartmentName_Validating(object sender, CancelEventArgs e)
{
cmbDesignation.Focus();
}
private void cmbDesignation_Validating(object sender, CancelEventArgs e)
{
cmbQualification.Focus();
}
private void cmbQualification_Validating(object sender, CancelEventArgs e)
{
txtSalary.Focus();
}
private void txtSalary_Validating(object sender, CancelEventArgs e)
{
if (txtSalary.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtSalary.Focus();
}
else
{
maskedtxtHireDate.Focus();
}
}
private void txtSalary_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show("Insert Integer only");
txtSalary.Focus();
}
}
private void maskedtxtHireDate_Validating(object sender, CancelEventArgs e)
{
if (maskedtxtHireDate.Text == "")
{
MessageBox.Show("You cannot leave it blank");
maskedtxtHireDate.Focus();
}
else
{
txtUserName.Focus();
}
}
private void txtUserName_Validating(object sender, CancelEventArgs e)
{
if (txtUserName.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtUserName.Focus();
}
else
{
txtPassword.Focus();
}
}
private void txtPassword_Validating(object sender, CancelEventArgs e)
{
if (txtPassword.Text == "")
{
MessageBox.Show("You cannot leave it blank");
txtPassword.Focus();
}
else
{
btnBrowseImagePath.Focus();
}
}
}
}
|
|
|
|
|
I created Windows Service in C#.net
In this Windows Service I successfully connect to local sql server 2000 install in My PC.Then I retrive data from local sql server 2000 and fill that data into one dataset.Now I Want to connect to remote sql server 2000 to insert that data into database of that sql server 2000.
|
|
|
|
|
Seems like changing the connectionstring is enough to change database. Have you changed your connectionstring to connect another database. Is it possible for you ti share the code.
|
|
|
|
|
You can keep the connection strings in app.config file under the onnectionstrings section and read it using ConfigurationManager.ConnectionStrings
|
|
|
|
|
Hi.
I've created a service and installed it with following code :
public static void InstallService(string ExeFilename)
{
System.Configuration.Install.AssemblyInstaller Installer = new System.Configuration.Install.AssemblyInstaller(ExeFilename, new string[] { });
Installer.UseNewContext = true;
Installer.Install(null);
Installer.Commit(null);
}
I wanna start it after install, could you please guide me how I can do it ?
Thanks.
|
|
|
|
|
|
|
I am creating a custom control derived from ComboBox. I add some items to custom control in constructor of control.
// this code is sample
public MyCustomControl
{
this.Items.Add("test1");
this.Items.Add("test2");
}
When I drag this custom control to my form, designer auto-generate the code:
// this code in Form1.Designer.cs
this.mycustomControls.Items.AddRange(new object[] {
"test1",
"test2"});
When this custom control display on Form1, will have 4 items:
test1
test2
test1
test2
This problem cause duplication.
Please help me how to solve this problem, I don't want designer auto-generate these codes. Thanks.
|
|
|
|
|
can anyone explain me that how to show a form from windows service. i search google but found no solution. please explain anyone.
Thanks in advance
tbhattacharjee
|
|
|
|
|
The Question is how do you Display a Form ?
Form1 frm1 = new Form1();
frm1.Show();
i have not been doing win apps for a while now , but that is how its done.
My point is that need to create that form first and show it later.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Tridip Bhattacharjee wrote: How to show a form from windows service?
Windows services don't interact with the user using UI.In fact they are "background" processes and it's not not safe to control the UI outside of the default drawing pool.If you need to control the service programatically
define your own custom commands and send them to the service using ServiceController.ExecuteCommand method.See this sample.And if you need to report for some errors use the event log.
Life is a stage and we are all actors!
|
|
|
|