|
How to make DataGridView column to input only numeric data, with filtering literals?
|
|
|
|
|
You can handle the KeyDown event and check if the character was a numeric or not. If not you should set e.SuppressKeyPress to true.
Regards
|
|
|
|
|
Hi.
Can someone tell me where/if I can find freeware graph/chart controls/libraries for .NET? I'm not interested in trial or evaluation versions of comercial libraries, but something basic and free. All I need is draw a simple, 2D bar chart on my C# Windows App.
Thanks.
|
|
|
|
|
There are lots of chart control in codeproject. Try to search it.
|
|
|
|
|
|
Let's say I have a cmdButton sitting on my form. It's a generic "Cancel" button, and I want it to perform different operations depending on which of my methods showed it.
Given that, how do I assign a handler to the Click event for the button?
I'm sure this is much more simple than I'm making it, but I've tried eleventy-seven different syntaxes, and I'm not getting it.
Thanks!
|
|
|
|
|
Well, Joe, this is how it appears in the Designer.cs code, if you allow VS to do it:
this.tsCmdBtn.Click += new System.EventHandler(this.tsCmdBtn_Click);
Does this help?
|
|
|
|
|
It sure does. Thanks, Batman!
|
|
|
|
|
Hey Joe, what about Psychoanalysis?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi all,
I am a beginner for C# and trying to study about ADO.NET. I wrote a simple application with a datagridview and three text boxes. I can populate data from table. Now I am trying to insert a record to a table. When I execute the following code, it is updating that table only a blank line. please can you help me to solve this problem? Or any other ways to update a record better than this?
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Data.SqlClient;<br />
<br />
<br />
namespace FundOrg<br />
{<br />
public partial class frmBankDetails : Form<br />
{<br />
<br />
private DataSet dsBank;<br />
private SqlDataAdapter da = new SqlDataAdapter();<br />
SqlConnection myConnection = new SqlConnection();<br />
<br />
<br />
private static frmBankDetails frmB = null;<br />
public static frmBankDetails Instance()<br />
{<br />
if (frmB == null)<br />
{<br />
frmB = new frmBankDetails();<br />
}<br />
return frmB;<br />
<br />
}<br />
<br />
public frmBankDetails()<br />
{<br />
InitializeComponent();<br />
<br />
<br />
<br />
<br />
myConnection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbcon"];<br />
<br />
try<br />
{<br />
myConnection.Open();<br />
}<br />
catch (SqlException E)<br />
{<br />
MessageBox.Show("Connection Erro : " + E.Message);<br />
}<br />
<br />
<br />
SqlCommand cmd = new SqlCommand("SELECT * FROM Bank_Details", myConnection);<br />
<br />
<br />
da.SelectCommand = cmd;<br />
dsBank=new DataSet();<br />
da.Fill(dsBank,"Bank_Details");<br />
<br />
<br />
dgBankCode.DataSource = dsBank;<br />
dgBankCode.DataMember = "Bank_Details";<br />
<br />
<br />
dgBankCode.RowHeadersVisible = false;<br />
<br />
dgBankCode.Columns[0].HeaderText = "Bank Code";<br />
dgBankCode.Columns[1].Visible = false;<br />
dgBankCode.Columns[2].Visible = false;<br />
<br />
txtBankCode.DataBindings.Add("Text", dsBank, "Bank_Details.Bank_Code");<br />
txtBankName.DataBindings.Add("Text", dsBank, "Bank_Details.Bank_Name");<br />
txtAccNo.DataBindings.Add("Text", dsBank, "Bank_Details.Acc_No");<br />
dgBankCode.ReadOnly = true;<br />
}<br />
<br />
<br />
public void SaveEntry()<br />
{<br />
<br />
<br />
SqlCommand cmdUpdate = new SqlCommand();<br />
cmdUpdate.CommandType = CommandType.Text;<br />
cmdUpdate.CommandText = "INSERT INTO Bank_Details(Bank_Code,Bank_Name,Acc_No) VALUES('"+ txtBankCode.Text +"','"+ txtBankName.Text +"','"+ txtAccNo.Text +"')";<br />
cmdUpdate.Connection = myConnection;<br />
<br />
cmdUpdate.ExecuteNonQuery();<br />
<br />
<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
}<br />
}<br />
And can anybody explain me, what are the good/bad coding practices with this?
Thanking you
|
|
|
|
|
MySQLString = "INSERT INTO Bank_Details(Bank_Code,Bank_Name,Acc_No)" +
"VALUES('"+ txtBankCode.Text +"','"+ txtBankName.Text +"','"+ txtAccNo.Text +"')";
SqlConnection MySqlConn = new SqlConnection(MyConnectionString);
SqlCommand MySqlComm = new SqlCommand(MySQLString, MySqlConn);
MySqlComm.Connection.Open();
MySqlComm.ExecuteNonQuery();
MySqlComm.Connection.Close();
mwith wrote: And can anybody explain me, what are the good/bad coding practices with this?
When working with DB try your best to keep it simple.
Also, check the SQL statement if Bank_Code and Acc_No are 'int' data types then you need to convert the textboxes from string to int. i.e. Convert.ToInt32(txtBankCode.Text)
Good Luck,
Jason
-- modified at 12:01 Thursday 11th January, 2007
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
|
Hello,
I am using the TreeView control in form application of C#.
I am having my own classes which are derived from TreeNode and i am adding the object of these classes to treeview as a node.
I want to serialize and deserialize the TreeView and i am doing it with BinaryFormatter object.
It get serialized properly but when i am loading it back it flashes an error "The constructor to deserialize an object of type 'MyTreeNode' was not found".
What else i need to add to get this done.
Thanks in advance
Gajesh
Pune(India)
-- modified at 2:17 Thursday 11th January, 2007
|
|
|
|
|
hi
friends i have an windows exe file
i want to knwo whether i can run exe without .netframework installed on the system or not
if it can be done how can i embeed the required dll's to my project....
thanking u ./.
byebye
|
|
|
|
|
This gets asked so often, and the answer is no. You can buy expensive frameworks that do it, but for the rest of us, we need to install .NET, that's a keo component of how it works.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Sure, don't develop it in .NET Winforms. Winforms are a joke.
|
|
|
|
|
Hi, Iam trying to parse XMLdata in c#.
please see the XMl data:
<response>1000 <message><mbit version="2"><share><id>29<title>up<description>up<file><id>26<name>up5454.bmp<type>allfiles<size>8910<checksum>9839B8107FF
3D117BDD67139D8318D29<chunks><chunk><id>45<checksum>9839B8107FF3D117BDD67139D8318D29
Iam using code:
XmlTextReader reader = new XmlTextReader(new StringReader(xmldata));
Exception coming while parsing due to xml declaration line.How to omit that line?Any idea?
Thanks
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
<response>
<code>1000</code>
<message>
<mbit version="2">
<share>
<id>29</id>
<title>up</title>
<description>up</description>
<file>
<id>26</id>
<name>up5454.bmp</name>
<type>allfiles</type>
<size>8910</size>
<checksum>9839B8107FF3D117BDD67139D8318D29</checksum>
<chunks>
<chunk>
<id>45</id>
<checksum>9839B8107FF3D117BDD67139D8318D29</checksum>
</chunk>
</chunks>
</file>
</share>
</mbit>
</message>
</response>
Looks like your XML is valid. I wouldn't expect an exception because of the top item, not at all. What's the error ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi All
I Am interfacing a microcontroller from C3 the protocol i choose is modbus Do any one have an idea or code about the modbus in C#
SAs
|
|
|
|
|
So I have the current date in a string by doing this:
string date=DateTime.Now.ToShortDateString();
So on a single digit day/month it will show up without a leading zero. Like today for example:
1/10/2007
I was messing around with the format specifiers of toString but I cant figure out a way to get a leading zeros on single digit days. How can I do this short of some string spitting.
/\ |_ E X E GG
|
|
|
|
|
Using the ToShortDateString is causing your problem. This call uses the Short date format specified in the "Regional and Language Options" control panel.
To have complete control over how the string is formatted, you would want to use the ToString method and pass in the format string. For your example, the call would look like this:
string date = DateTime.Now.ToString("MM'/'dd'/'yyyy");
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
OK, thanks I didn't know it was that flexable!
/\ |_ E X E GG
|
|
|
|
|
No problem. Most of the ToString methods, particulary on the DateTime and native numeric data types (int, short, etc.), take some sort of format string.
Here is the MSDN page that will give you information on all of the different formatting options available for the different data types:
http://msdn2.microsoft.com/en-us/library/fbxft59x.aspx[^]
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
This is a repost as I didn't get a reponse to my last one and I still can't get this thing to run through. Well I lie. It ran through fine once, but since then I've been getting this contextSwitchDeadlock issue, but I haven't modified the code!
Anyone have any ideas?
/TH
<br />
Hi All,<br />
<br />
I'm slowing finding my way around C#.<br />
<br />
I have written an application that takes a directory, take each file in that directory and also each file in each subdirectory, and then trys to find any files with the same name<br />
<br />
(Trying to clear up all my duplicate photos )<br />
<br />
SO I have written the code, and checked it and checked it again, it does not get caught in an infinite loop.<br />
<br />
But when I F6 the app it comes up with a ContextSwitchDeadlock MDA issue.<br />
|
|
|
|
|
My friend...
Even though I've never faced a contextSwitchDeadlock, but I think that googling[^] is a very healthy practice.
Regards
|
|
|
|
|
Hi Nader,
I tried that. found something about setting it to "Full Trusted" which i tried, but that did not resolve it.
Thanks for the help though!
|
|
|
|