|
Use Char.IsNumber(char c)
or parse it, for example Int32.Parse(string s);
if you get an exception, that means your
string is not a number.
|
|
|
|
|
int n;
if(int.TryParse(s, out n))
{
// n now contains your int
}
else
{
// was not a number.
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi everybody!
I'm trying to serialize an object (PrintableListView that was posted on the site). to do that I created a class that will hold my object, and I marked it as [Serializable()].
The problem is that on the line:
bformatter.Serialize(stream, serial.plv);
when I'm trying to serialize the serial.plv (I marked plv as public), I get an exception, saying "Type 'PrintableListView.PrintableListView' in Assembly 'PrintableListView, Version=1.0.2088.26378, Culture=neutral, PublicKeyToken=null' is not marked as serializable." although I did marked the class as Serializable().
Does anyone have any Idea what could be wrong and how to fix it???
THANKS ALOT!!!
|
|
|
|
|
Hi,
PrintableListView is derived from ListView class. And the ListView class is not declared [Serializable()]. Thats why you cannot serialize the derived class PrintableListView objects.
If you want to save some data between the application runs then you can programmatically save the data to a text or binary file and read the data into the control when you start application next time.
Hope this helps !
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
Thanks alot! I thought thats the case, but I hoped it wasn't.
oh well...
|
|
|
|
|
I am very needly your help.
I am doing update data from DataSet to DataBase using SqlDataAdapter and using SqlCommandBuilder. , but don't successfully.
Thank you very much.
|
|
|
|
|
hi
could you provide your code, so that we can help you !!
Tamimi - Code
|
|
|
|
|
Thanh you very much.
Today i have a example so that I am very your help.
My Code is very dirty.
But I will send you.
Step1. I create A class ClsLogin in a file : "lsLogin.cs"
<br />
public class ClsLogin<br />
{<br />
public string userName;<br />
public string passWord;<br />
public static SqlDataAdapter SQLDataAdapter;<br />
public static DataSet ODataSet;<br />
public SqlCommand sqlcom;<br />
public SqlCommandBuilder sqlBuilder;<br />
}<br />
Step 2.I Create a Class User in a file: "ClsUser.cs"
<br />
public class ClsUser<br />
{<br />
public ClsUser()<br />
{}<br />
public DataSet FillUser()<br />
{<br />
ClsLogin oClogin = new ClsLogin();<br />
ClsLogin.SQLDataAdapter = new SqlDataAdapter("SELECT * FROM tbl_Employee",ClsConnection.SQLConnection);<br />
ClsLogin.ODataSet = new DataSet();<br />
try<br />
{<br />
ClsLogin.SQLDataAdapter.Fill(ClsLogin.ODataSet,"User");<br />
<br />
oClogin.SQLCOMBUILDER =new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
return ClsLogin.ODataSet ;<br />
<br />
}<br />
catch(Exception ex)<br />
{<br />
throw ex;<br />
return ClsLogin.ODataSet;<br />
}<br />
}<br />
}<br />
Step3. i binding data to Datagrid in my form in file: "MyWindfor.cs"
<br />
private void btnLoad_Click(object sender, System.EventArgs e)<br />
{<br />
this.CheckLoad();<br />
}<br />
private CurrencyManager oCm;<br />
private DataSet oDs;<br />
private void CheckLoad()<br />
{<br />
<br />
ClsUser oUser =new ClsUser();<br />
try<br />
{<br />
oDs = oUser.FillUser();<br />
this.dataGrid1.DataSource = oDs.Tables["User"];<br />
this.oCm = (CurrencyManager)BindingContext[oDs.Tables[0]];<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show("Lỗi sảy ra: " +ex.Message +":"+ex.Source);<br />
}<br />
}<br />
. Finish to Here is Success. Data in DataBase displayed in Datagrid if click btnLoad.
***** But my Problem is:*****
I have a button : name = btnDelete in file "MyWindform.cs". And I writed code to delete a row in dataset, after I want update dataset to "Database" As.
<br />
private void btnDelete_Click(object sender, System.EventArgs e)<br />
{<br />
ClsLogin.ODataSet.Tables[0].Rows.RemoveAt(this.oCm.Position);<br />
ClsLogin oLogin =new ClsLogin();<br />
<br />
oLogin.sqlBuilder= new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
<br />
}<br />
Then you Click btnDelete: a Row in table of Dataset deleted. But Data Datasource don't Update. Didn't change.
Help Me.
|
|
|
|
|
is your dataset typed dataset ??
Tamimi - Code
|
|
|
|
|
What do typed DataSet effect in my Code?.
I don't know about type DataSet.
I am honest thank your help.
Thank to your care.
|
|
|
|
|
Hi,
I'm displaying a jpg file in a Panel control with a "stretch to fit" option. When I start resizing the form that owns the panel the image resizes with it, but it flickers and it's really annoying. Is there a way to eliminate this?
thanx
|
|
|
|
|
Use the SetStyle method to turn on double buffering.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I've already tried this, but I can only call SetStyle on the form containing the panel. The flicker is still there, though.
|
|
|
|
|
The Panel needs to be double buffered. If you can't call SetStyle externally, derive a class from Panel and try that
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Just tried it.. same thing.
|
|
|
|
|
Found the problem: I need to set AllPaintingInWmPaint as well. So it's like this:
SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer,true);
thanx
|
|
|
|
|
i want to know how to get the serial number of motherbord ,harddisk,etc with c# code
|
|
|
|
|
Windows Management Instrumentation (WMI)
|
|
|
|
|
As someone else said, WMI. The problem is, you'll find you can't access it unless your user is admin.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello omar,
I think this is usefull to u.
-- modified at 6:48 Friday 18th August, 2006
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
I wrote a program for my company that uses the SQL MSDE. I would like to know what class/function to use to retrieve the SQL server instance, computer name, and the path for the current users My Document folder. I will use this information to create the connection string on the fly. Is that a good idea or bad programming practice? If it is bad, what is an alternative?
Also, whats a good/free installer program I can tinker with?
Thanx in advance!
Jude
|
|
|
|
|
It's something like Enviroment.GetSpecialFolder to get the My Documents folder ( among others, it takes an enum ).
Advanced Installer has a free version, I've found it quite good.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Was that a point to do my own work or are you not sure??LOL...Thanx!
Jude
|
|
|
|
|
*grin* I was flat out and going from memory. That should be enough for you to find it, if not, just give me another yell.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanx brother..but about getting that info to do on the fly sql connections...good programming practice or not?
UPDATE
I looked at MSDN Library and got this:
[C#]
// Sample for the Environment.GetFolderPath method
using System;
class Sample
{
public static void Main()
{
Console.WriteLine();
Console.WriteLine("GetFolderPath: {0}",
Environment.GetFolderPath(Environment.SpecialFolder.System));
}
}
When I try to type Environment.SpecialFolder, Intellisense does not pop up..is this a valid property in C#? If so, what do I add to it?
Thanx
EDIT
Ok, got it..a environment class and enum
-- modified at 23:34 Wednesday 16th August, 2006
-- modified at 23:41 Wednesday 16th August, 2006
-- modified at 16:19 Thursday 17th August, 2006
Jude
|
|
|
|