|
Hai
Me with C#.net I want to make a text box to accept only numbers and decimal points(decimal point only once), so I tried to make a user control and is working fine except one problem. If if select all the data in the text box and try to enter a new value decimal point will not accept until I press the backspace. My user control code is a follows
string i;
int f;
public string Text
{
get
{
return NMTextBox.Text;
}
set
{
NMTextBox.Text = value;
}
}
private void NMTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
string numaric = NMTextBox.Text;
for (int j = 0; j < numaric.Length; j++)
{
char myChar = numaric[j];
}
if (NMTextBox.Text == "")
{
f = 0;
}
if (e.KeyChar.ToString() == ".")
{
++f;
if (f >= 2)
{
e.Handled = true;
}
}
if (i == "8")
{
f = 0;
for (int j = 0; j < numaric.Length - 1; j++)
{
if (numaric[j].ToString() == ".")
{
++f;
}
}
}
if (e.KeyChar.ToString() != "." && Char.IsNumber(e.KeyChar) != true)
{
if (i != "8")
{
e.Handled = true;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, ex.Message.ToString());
}
}
private void NMTextBox_KeyDown(object sender, KeyEventArgs e)
{
i = e.KeyValue.ToString();
}
Thanks & Regards
|
|
|
|
|
If InStr(sTotalRows, "TOP 100 PERCENT *", CompareMethod.Text) > 0 And Trim(sCondition = "") Then
'If db.Tables.Item(sTableName).Rows > 0 Then
db.Tables.Item(sTableName).ExportData(objBCPExport)
'End If
Else
Dim sSelectCommand As String = "select " + sTotalRows + " from " + sDatabaseName + ".." + sTableName
If Trim(sCondition) <> "" Then
sSelectCommand += " WHERE " + sCondition
End If
'Create a temporary view to hold data
Try
db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
Catch
End Try
db.ExecuteImmediate("create view Temp_View_For_Backup_001 as " + sSelectCommand, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
db.Views.Refresh()
'db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCP)
'Export data to a file
db.Views.Item("Temp_View_For_Backup_001").ExportData(objBCPExport)
Try
db.ExecuteImmediate("drop view Temp_View_For_Backup_001", SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_Default)
Catch
End Try
End If
|
|
|
|
|
There are lots of tools for this, but I assume no one is perfect. Do it manually.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
First just write in simple english what this code does and then think how to write that in C#
I think that's the simplest method
|
|
|
|
|
To Convert to C# from another Language you must Understand C#
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.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
How do made xml file that read or write in ?
|
|
|
|
|
Check this link[^]
Regards,
Lev
|
|
|
|
|
There are classes available and by using objects of those classes u can read/write in XML file
google it!
|
|
|
|
|
I want add control to form and then use the event dubleclick for control? help me thanks..
|
|
|
|
|
When u create the object of your control also register the event with it by using += operator
concept of delegates
|
|
|
|
|
Hi All,
does anybody have an idea of how to generate an eqivalent CAML query for the following SQL statement
"select max(IntColm) from Table group by StringColm"
Thanks in advance..
Red October
modified on Tuesday, December 30, 2008 12:06 AM
|
|
|
|
|
what the function to get the name of the node itself ( Request)?
<request num_param="0" bytecount="0">
|
|
|
|
|
hung1984 wrote: what the function to get the name of the node itself ( Request)?
The Name of the node? Could that be what the Name[^] property is for?
|
|
|
|
|
I have 1 xml file :
<myxml>
<common>
<number a="0" des="int">
<number a="1" des="doub">
i want to get value of "a" and "des" node, my code below get wrong?
XmlDocument Reader = new XmlDocument();
Reader.Load("MyXml.xml");
XmlNodeList List = Reader.SelectNodes("/MyXml/common/Number");
foreach (XmlNode node in List)
{
int i = int.Parse(node["a"].InnerText);
des[i]= node["des"].InnerText;
}
thanks
|
|
|
|
|
If you are going to include XML in your post either manually escape the XML characters or check the "Ignore HTML tags in this message (good for code snippets)" box for the post (below the smilies and above the submit button)
If you are using .NET 3.5 there are new and better classes for querying XML.
|
|
|
|
|
If node a and des have attribute called "name" then you can get the value of that attribute by following
foreach (XmlNode node in List)
{
int i = int.Parse(node["a"].Attributes["name"].Value;);
des[i]= node["des"].Attributes["name"].Value;
}
|
|
|
|
|
Hi
I want to do a project where I need to calculate the intersection of the two cubes but I don't now how i can calculate the volume of this intersection. This is the project
Create a small web application that allows a user to enter the dimensions and coordinates of two cubic objects in a 3-dimensional space. Once the information has been entered, the web application should calculate if the two cubes intersect, and if so, what the volume of the shared space is.
Note, the coordinates specify the CENTER of the cube!
Sample Data:
Cube A: Size = 5m x = 10m
y = 10m
z = 0
Cube B: Size = 2m x = 9m
y = 9m
z = 1m
Answer: Do the cubes intersect? What is the volume of the shared space?
|
|
|
|
|
Guys,
I am trying to save the hidden panel contents to an image using GDI+.
I do not want to resize the panel to show all the contents and then save it.
I would like to keep the panel at the default size and save all the hidden contents without scrolling.
Thx.
|
|
|
|
|
Image image = this.panel1.BackgroundImage;
image.Save("1.jpg");
Tan Li
I Love KongFu~
|
|
|
|
|
Thx for the response.
The contents on my panel are custom drawn items. I would to save everything (hidden items as well) to a image file without scrolling or resizing the panel.
|
|
|
|
|
Well, about this, I do not know how to save the graphic objects into a file directly. However, you can save a image through Bitmap. Such as:
Bitmap bitmap = new Bitmap(400,400);
Graphics g = Graphics.FromImage(bitmap);
Pen pen = new Pen(Color.Black);
g.DrawEllipse(pen, new Rectangle(10, 10, 200, 200));
bitmap.Save("test.jpg");
Hope this will help you~
Tan Li
I Love KongFu~
|
|
|
|
|
Hi,
I have Form app that includes a DataGridView control (bound to DataTable). The user can sort the columns by clicking the column headers.
If the user has clicked the Date header (to sort the column), the code below fails to update all rows in the DataGridView (and Database). The list is fairly large (few hundred), so I can only guess that when a certain number of rows are updated (via - row.Cells["Col_ItemAddedDate"].Value = newItemDate;) a resort occurs that mucks up the foreach loop? If I don't update the DGV cell, the loop works fine to update database.
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
OleDbCommand myCommand = new OleDbCommand("UPDATE Products SET ItemAddedDate=? WHERE ItemID=?", myConnection);
myCommand.Parameters.Add("@ItemAddedDate", OleDbType.Date).Value = newItemDate;
myCommand.Parameters.Add("@ItemID", OleDbType.BigInt).Value = row.Cells["ItemID"].Value;
// execute the command
myCommand.ExecuteNonQuery();
// THIS CODE CAUSES THE LOOP TO FAIL (if the Col_ItemAddedDate column header is clicked to sort)
// Some of the rows are updated, but some do not (both Database UPDATE and the DGV cell update will fail)
row.Cells["Col_ItemAddedDate"].Value = newItemDate;
}
Ron
modified on Monday, December 29, 2008 6:40 PM
|
|
|
|
|
I'm using TableAdapter.Update() to insert data to database. Is there a way to update ID columne value of the inserted row in the DataSet, hopefully without select @@identity/scope_identity() method?
|
|
|
|
|
Hello,
Last time I asked how can I create an sql server alias programatically,
and Mika gave me a great link which works great.
This is what I am doing:
ManagementScope scope = new ManagementScope(@"\\" + client + @"\root\Microsoft\SqlServer\ComputerManagement");
ManagementClass clientAlias = new ManagementClass(scope, new ManagementPath("SqlServerAlias"), null);
clientAlias.Get();
ManagementObject alias = clientAlias.CreateInstance();
alias.SetPropertyValue("AliasName", aliasName);
alias.SetPropertyValue("ServerName", server);
alias.SetPropertyValue("ProtocolName", prot);
alias.SetPropertyValue("ConnectionString", conn);
alias.Put();
If the client is my local computer - works greate.
If it is a remote connection, I keep getting access denided.
What priviliges do I need ?
I tried using ConnectionOptions with user that has administrator priviligies on the client - didn't work.
Thanks
Calanit
|
|
|
|
|
Does your SQL Server permit remote connections? Is the user defined in the connection string permitted access. If you are using a trusted connection, is it a domain user?
|
|
|
|