|
|
Assume this function:
private void Changing(int[] is, int i)
{
is[0] = 100;
i = 100;
}
When I call Changing in Main:
static void Main()
{
int[] is = {0, 1, 2, 3, 4};
int i = 0;
Console.WriteLine(i);
Console.WriteLine(is[0]);
Changing(is, i);
Console.WriteLine(i);
Console.WriteLine(is[0]);
}
is changed but i didn't, why?
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Arrays in C# fall in the category of reference types. Like any other reference type, an array object refers to a memory space allocated on the heap.
If you want to deep knowledge then go to Google for Value Type vs Reference Type.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Ok, I got it, Tha nks
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hi, I am using VS C# 08 Express Edition and I have a personal web browser that I've almost finished, and on Form1_Load the web browser will goto my custom homepage. But I am not sure how to go about this. I want to have the HTML file that I've created to either be installed with the program when someone installs my program or have it embeded into the .Exe file somehow, is either way possible? Can somebody please explain how to do this? Thanks in advance
regards,
jt
|
|
|
|
|
jay_t55 wrote: when someone installs my program or have it embeded into the .Exe file somehow, is either way possible?
yes it's possible.
if you want your html file to be installed with your program, just add it to your installer. otherwise you can include that file as embedded resource in your application and get the stream of your resource with YourAssembly.GetManifestResourceStream(YourEmbeddedFileResourceName).
hope it helps
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Thanks mate, i appreciate your help! I spent about three weeks trying to figure that one out (i'm a newbie)
|
|
|
|
|
I've ran into a subtle but problematic issue with the DataGridView saving a new row. I have a databound dgv stored in a UserControl and when the user enters values into a field, the values are not updated when the UserControl is closed (removed from the form). To save time I won't do into an explanation on why the dgv resides in a UserControl but I promise that there is a legitimate reason. Does anyone know how to force the dgv to save state of the new row being edited? If the user enters values into a new row and moves to another row, the state is saved but I can't depend on that happening in a real world situation. I have tried: dgv.NotifyCurrentCellDirty(), dgv.EndEdit() etc and nothing is working.
Here is how to replicate this issue. (Maybe a bug)
Try dropping a dgv that is bound to a dataTable into a UserControl. Now drop the UC inside a Form. Have a MenuStrip item that can be clicked to remove the UserControl from the form. Run the application and add some text to the new row at the bottom. Now without moving the cursor to another cell, click the MenuStrip to remove the UserControl. Now run the program again and the new row's state will not be saved. Enter some text again into the new row at the bottom and close the Form this time. The new row should save state this time.
Thanks for any help that can be provided.
Richard
I've used up all my sick days, so today I'm calling in dead.
|
|
|
|
|
Hi,
how can i set data in a IFieldObject, i place that kind of "textboxes" in a myreport.rpt and i want to set data there as i do in ordinary winforms textboxes.
I want to do this the "same" way i fill a datagridview.
public static void DataGridView_Fill(DataGridView data_grid_view, string store_procedure)
{
SqlConnection sql_conn = new SqlConnection(connection_string);
SqlCommand sql_cmd = new SqlCommand();
sql_cmd.Connection = sql_conn;
sql_cmd.CommandText = store_procedure;
sql_cmd.CommandType = CommandType.StoredProcedure;
sql_conn.Open();
SqlDataAdapter sql_da = new SqlDataAdapter();
sql_da.SelectCommand = sql_cmd;
DataTable dt = new DataTable();
sql_da.Fill(dt);
sql_conn.Close();
data_grid_view.DataSource = dt;
}
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I am trying to use the example mentioned as compatible across the platform to generate a MD5 hash. http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5cryptoserviceprovider.aspx#[^]
My other system would generate MD5 hash through PHP function. For some reason, the two does not seem to tally. I have also used a simple Java Code to generate MD5. Java and PHP identically generate the same hash for a given string but this one generates a totally different one.
Any clues?
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
|
|
|
|
|
I've come accross this before but a long time ago - I haven't used MD5 in quite a while.
This is[^] one I had bookmarked, I don't know if I ever tried it - but should hopefuly help.
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 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.
|
|
|
|