|
Thanks for the assistance.
In the URL, one of the example uses 'X' (.toString("X")) instead of 'X2'. This seems to be working for me. Thanks again.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
What are you hashing? If you have numeric values in your stream you may find that storing the numeric values in network byte order will cause the function to output correctly.
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.
|
|
|
|
|
@Ennis,
DaveyM69 suggested another trick to change the format specifier and that seems to be working. Anyway, later I would also try using your suggestion 'network byte order'
Thanks for the assistance.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
Check the encoding of your input data. Your .Net end may be using unicode strings instead of ascii.
|
|
|
|
|
Hi guys, I have two items in a contextmenu if i click on Play button then in my ClassB the event get fired but if i click on Color it crahes becuase myevent is null. i want to fire event if it is called from ClassB then call it's event and if it called from ClassA run its event.
Class A
{
public virtual event CEventHandler myevent;
MenuItem[] menuItms = new MenuItem[]{ new MenuItem("Color", new EventHandler(Color))}
ContextMenu.MenuItems.Add(menuItms);
private void Color(Object sender, EventArgs e)
{
if(myevent!=null)
myevent(sender, e);
}
}
Class B: A
{
public override event CEventHandler myevent;
MenuItem[] menuItms = new MenuItem[]{ new MenuItem("Color", new EventHandler(Play)}
ContextMenu.MenuItems.Add(menuItms);
private void Play(Object sender, EventArgs e)
{
if(myevent!=null)
myevent(sender, e);
}
}
modified on Wednesday, October 8, 2008 6:13 PM
|
|
|
|
|
Virtual events are one of those things they (MS) whish they could uninvent! Overriding the event does not create a new event hence your null problem.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
you r right but perhaps a sample would be good enough to make newbie happy. However, I found the solution.....Had to declared a method in the baese class and call that method from the derived class and passed the information to the base class
|
|
|
|
|
I am reading the contents of excel file and storing contents in database.
I am using two datatables org_dt and grid_dt.
i am having a problem while adding rows to grid_dt datatable, also having problem while inserting date into this table.
here is the source code:-
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.Odbc;
using Excel;
namespace WinApp_STRINGSEPARATE
{
public partial class Frm_admin_upload_optn : Form
{
string connectionString;// @" Dsn=Excel Files;dbq=C:\Program Files\Common Files\ODBC\Data
Sources\book4.xls;defaultdir=c:\;driverid=790;maxbuffersize=2048;pagetimeout=5";
OdbcConnection conn = new OdbcConnection();
OdbcCommand cmd = new OdbcCommand();
OdbcDataReader dr;
System.Data.DataTable org_dt = new System.Data.DataTable();
System.Data.DataTable grid_dt = new System.Data.DataTable();
string project_no = "", summary = "";
string[] divpara = new string[3];
string[] yes = new string[4];
public Frm_admin_upload_optn()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
textBox1.Text = openFileDialog1.FileName;
}
private void Frm_admin_upload_optn_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
try
{
connectionString = @"Dsn=Excel Files;dbq=" + textBox1.Text.Trim()
+";driverid=790;maxbuffersize=2048;pagetimeout=5";
conn.ConnectionString = connectionString;
cmd.CommandText = "SELECT * FROM [sheet1$]";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = conn;
conn.Open();
dr = cmd.ExecuteReader();
org_dt = new System.Data.DataTable();
if (dr.HasRows)
{
org_dt.Load(dr);
grid_dt.Columns.Add("PROJECT NO");
grid_dt.Columns["PROJECT NO"].DataType = typeof(string);
grid_dt.Columns.Add("TICKET NO");
grid_dt.Columns["TICKET NO"].DataType = typeof(string);
grid_dt.Columns.Add("REPORTED DATE");
grid_dt.Columns["REPORTED DATE"].DataType = typeof(DateTime);
grid_dt.Columns.Add("OLD COMPUTER NAME");
grid_dt.Columns["OLD COMPUTER NAME"].DataType = typeof(string);
grid_dt.Columns.Add("NEW COMPUTER NAME");
grid_dt.Columns["NEW COMPUTER NAME"].DataType = typeof(string);
DataRow grid_dt_row = grid_dt.NewRow();
for (int j = 0;j<4;j++ )
grid_dt_row[j] = "";
int count_orgdt = org_dt.Rows.Count;
int i = 0;
foreach (DataRow drow in org_dt.Rows)
{
summary = drow["summary"].ToString();
if (summary != "")
{
if (summary.Contains("Project #-"))
project_no = "Project #-";
else project_no = "Project Number #-";
divpara[0] = project_no;
divpara[1] = "New PC Name :";
divpara[2] = "Old PC Name :";
yes = summary.Split(divpara, System.StringSplitOptions.None);
//grid_dt.Rows.Add(grid_dt_row);
grid_dt.ImportRow(grid_dt_row); //ERROR MSG
grid_dt.Rows[i]["project no"] = yes[1];
grid_dt.Rows[i]["ticket no"] = drow[0];
grid_dt.Rows[i]["reported date"] =drow[3] ; // ERROR RELATED TO DATE FIELD
grid_dt.Rows[i]["old computer name"] = yes[2];
grid_dt.Rows[i]["new computer name"] = yes[3];
i++;
}
}
dataGridView1.DataSource = grid_dt;
}
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}
finally
{
conn.Close();
}
}
}
}
|
|
|
|
|
The error: "This row belongs to another table" is legitimate because the row contains a reference to the table that initiated it. (row.Table) If you are wanting to copy the row's data into another table with the same schema, try this syntax:
secondTable.Rows.Add(firstTableRow.ItemArray());
As to the date error, it would help if you could post the error text.
Cheers!
Richard Blythe
I've used up all my sick days, so today I'm calling in dead.
|
|
|
|
|
I created a combobox that binds to a datasource. If the combobox only contains one item, I programatically select the one item and want to trigger SelectionChangeCommitted event just as though the user had selected it. How can I call this event manually?
|
|
|
|
|
The OnSelectionChangeCommitted that raises the event is protected virtual so it is only accesible in derived classes. Therefore, I think the only way to call that method to raise the event is by your own class the derives from ComboBox:
public class MyComboBox : ComboBox
{
public void RaiseSelectionChangeCommitted()
{
base.OnSelectionChangeCommitted(EventArgs.Empty);
}
}
You can now use the RaiseSelectionChangeCommitted method to call the base method and raise the event. This is probably not advisable and there is probably a better way but it's all I can think of - and it works!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: This is probably not advisable and there is probably a better way but it's all I can think of - and it works!
If it works, do it![^]
led mike
|
|
|
|
|
LMFAO!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks! That's exactly what I was trying to do.
|
|
|
|
|
Is List<object> fundametally the same as ArrayList or should I prefer one over the other?
|
|
|
|
|
|
Man, you're about as popular with the 1-voters as John the Outlaw Programmer is. Are you running for his office??
|
|
|
|
|
Dave Kreskowiak wrote: Are you running for his office??
No, but perhaps I should care what some loser that doesn't even know what generics is and can't be bothered to read documentation to learn about it, thinks about my post? Nah, not so much.
led mike
|
|
|
|
|
The first, is a generic list specifically of type object. the second is a non generic list, written to hold object types.
If you use "object" in the generic one, then yes they are pretty similar. but why are you storing a list of objects? You should create you list with the specific type you want to store
i.e. List<String>
Doing this is wayyyy better than using an ArrayList to hold strings because the generic form enforces type safety, you don't have to cast, and you don't have to write a specific class. (And in the case of value types, prevents boxing)
You can do some reading on generics here:
Intro to C# generics[^]
Generics - C# programming guide[^]
Simon
|
|
|
|
|
I cannot tell the type of the data being collected at compile time. It could change based on the situation.
Brent
|
|
|
|
|
dbrenth wrote: I cannot tell the type of the data being collected at compile time.
Then use an ArrayList!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
if you're working with pure objects only then I don't think there's a great deal of difference. If not, the generic list is obviuosly far more flexible and much quicker as you can use any type without boxing/unboxing.
As there is no advantage to the ArrayList I never use them. This page[^] (is probably quite old) has a comparison of the two.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
For the most part the way you interact with a List<T> and an ArrayList are the same. They provide very similar functionality to the calling code.
Specifically, List<Object> is defining a generic list of type Object so from a data type point of view it is the same as ArrayList since ArrayList can only contain objects.
In general, I think it is preferable to use the generics, particularly if you are working with strong data types (things other than objects) as you are able to get better performance from the generics because you no longer have most (if not all) of the boxing/unboxing operations that need to be performed. That being said, by creating a List<Object> , you probably aren't really gaining a whole lot over an ArrayList .
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
List<object> and ArrayList are very similar, but there are some implementation differences:
The List<object> methods are not virtual and the List enumerator is a value type, whereas ArrayList requires virtual method calls and needs a heap allocation for the enumerator. So List<object> is a tiny bit faster than ArrayList .
I'd always use List<T> , even if you don't avoid any boxing and don't get any type safety in the List<object> case.
|
|
|
|
|
If you're not able to appreciate the difference, use the ArrayList . The other way passes through led mike's suggestion.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|