|
why not create a 2 column array and allow the user to edit it and then apply it as a data source to the grid?
Pakistani Memon
Prime Minister
Post Meridian
|
|
|
|
|
Sounds good, but how do I apply a 2D array as a data source to a datagrid?
|
|
|
|
|
you have two choice
either you create a 2-column data table
or
create a class with two properties and use the collection as an object data source to the data grid
Pakistani Memon
Prime Minister
Post Meridian
|
|
|
|
|
Sir/madam,
I wanted to know the basic difference between internal and internal protected .As i know both are accessible with in the drive class. and both are accessible under the object of their class.Both are accessible with in the assembly.
So my question is what is the basic bifference between them.
Thanks and regards
pankaj garg
|
|
|
|
|
amaneet wrote: I wanted to know the basic difference between internal and internal protected
internal means accessible only to other classes within the assembly.
internal protected means accessible only to derived classes within the assembly. No other classes (even within the assembly) can access something marked as internal protected .
|
|
|
|
|
Colin Angus Mackay wrote: internal protected means accessible only to derived classes within the assembly.
You sure about that? MSDN says[^] that internal protected grants access to classes that are within the same assembly or derived from the base class (even in external assemblies).
|
|
|
|
|
Vega02 wrote: internal protected grants access to classes that are within the same assembly or derived from the base class (even in external assemblies).
Oops! You're right. I must have misread that and thought that both conditions had to be satisfied. I stand corrected.
|
|
|
|
|
Hi!
i want to open different windows form on clicking differnt nodes. I am using node.tag property for giving url but in url i have to write like this:
node.Tag="C:\\Documents and Settings\\MyDocuments\\Visual Studio Projects\\WindowsApplication1\\General.cs";
and then after that i double click the tree view for getting its after_select event and in that event i write
System.Diagnostics.ProcessStartInfo iexploreStartInfo = new System.Diagnostics.ProcessStartInfo("iexplore.exe", e.Node.Tag.ToString());
System.Diagnostics.Process iexplore =
System.Diagnostics.Process.Start(iexploreStartInfo);
now when i click node the same page opens in the browser thats link is given in tag property but as i wrote general.cs in url the cs file opens. But i want to open that particular form and i m not getting how to do that. Can anybody help me in that problem.
Thanx
|
|
|
|
|
EEmaan wrote: now when i click node the same page opens in the browser thats link is given in tag property but as i wrote general.cs in url the cs file opens. But i want to open that particular form and i m not getting how to do that. Can anybody help me in that problem.
I'm sorry , your not clear at all. By Form do you mean the Form code thats in the General.cs file!? thats a little odd, you would have to compile the .cs file and then run the .exe! But why would you want to do that!??
Gideon
|
|
|
|
|
Hi all,
My application needs to upload an excel sheet into SQl server Databse using c#.
i written code like this.
OleDbConnection DbConn = new OleDbConnection"provider=Microsoft.Jet.OLEDB.4.0; data source='" + System.IO.Path.GetFullPath(File1.PostedFile.FileName) + " '; " + "Extended Properties=Excel 8.0;");
DbConn.Open();
OleDbCommand comm1 = new OleDbCommand();
comm1=DbConn.CreateCommand();
comm1.CommandText="SELECT * FROM [sheet1$]";
OleDbDataReader OldAdap;
OldAdap=comm1.ExecuteReader();
// File1 is an HTML input type=file.
and i am reding data. The problem here is, it is working fine when i run it on local machine(I am reading the excell sheet & contents are uploaded into SQL database). when i deploye it on the server it is giving an error
Failure creating file.
Please tell me the solution & what should i do to read the excel sheet.
Tahnks & Regards
S.Rajeshwar Reddy
|
|
|
|
|
Try out this......................
// Connection String.
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + FilePath + ";Extended Properties=Excel 8.0;";
// Create connection object by using the preceding connection string.
con = new OleDbConnection(connString);
// Open connection with the database.
con.Open();
// Get the data table containg the schema guid.
dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if(dt == null)
{
return null;
}
string[] excelSheets = new String[dt.Rows.Count];
int i = 0;
// Add the sheet name to the string array.
foreach(DataRow row in dt.Rows)
{
excelSheets[i] = row["TABLE_NAME"].ToString();
i++;
if(i==sheetNumber)
break;
}
OleDbCommand excelCommand = new OleDbCommand("Select * from ["+excelSheets[sheetNumber-1]+"]",con);
OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);
System.Data.DataTable importStudentsDT = new System.Data.DataTable();
excelAdapter.Fill(importStudentsDT);
return importStudentsDT;
My small attempt...
|
|
|
|
|
Hi all,
i have developed an windows application where in which, i want the current path where the project dll is residing,
i mean, here I'm refering to an XML file in the user control like(@"..\\..\xmlfile.xml"); but this path is taking to the application path[Two Up] --after i built this application to an .exe and excute its giving FileNotFound Excpetion.so,
i want the current path where the dll is residing,
Please help me.
Prashanth
|
|
|
|
|
private string CurrentPath = Environment.CurrentDirectory.ToString();
But watch out when using FileDialoges, it can give you the directory of the file/directory you choose.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Take a look at the Application.StartupPath property.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Please be aware that Application.StartupPath returns the path of the application that started the executable.
See: http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx
This path is not necessaraly YOUR application. If someone creates a laucncher for your application, if would return the path to their application not yours and also does not include the executable name.
The better method would be:
string path = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Application.StartUpPath will not work for projects having output type as 'class library'
use Environment.CurrentDirectory instead
Pakistani Memon
Prime Minister
Post Meridian
|
|
|
|
|
A similar problem exists when using Environment.CurrentDirectory as the current directory is not necessarily the folder in which your application resides.
You can test this yourself by creating a console application containing the following code:
public static void Main(string[] args)
{
Console.WriteLine("Current Directory: " + Environment.CurrentDirectory.ToString() );
Console.WriteLine("Press any key to continue...");
Console.ReadKey( true );
}
Now if you run the code, it does as you would expect.
But if you open your applications folder in explorer then right-click and 'create a shortcut', you can edit the properties of the shortcut and change the 'Start in' parameter to 'C:\'.
When you then run the application using the shortcut, the current directory is set to 'C:\' and not that of your application.
Please see my previous post for the correct method.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Hi all,
I've asked this question before, but didn't receive a response, so I'm posting it again but with more info which should HOPEFULLY help someone tell me what I'm doing wrong.
I am trying to use a DLL that modifies a stream of bytes (basically it's an encryption/decryption DLL). This DLL comes from someone else and I have to use it "as is" (no way to modify it).
The DLL reads and writes to a byte array (reads encrypted data, writes decrypted data), and this is giving me the error "Attempted to read or write protected memory."
I think the problem is quite simply that I don't understand how C# handles this kind of thing, so was wondering if I could get a little help.
The code goes something like this:
[DllImport("ABCdecrypt.dll", EntryPoint = "ABCdecrypt", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
unsafe public static extern bool ABCdecrypt([MarshalAs(UnmanagedType.I4)] int type, byte* data, int datalength);
private void buttonGo_Click(object sender, EventArgs e)
{
byte[] yData = File.ReadAllBytes(textBoxInput.Text);
unsafe
{
fixed (byte* pBuf = &yData[0])
{
ABCdecrypt(100, pBuf, yData.Length);
File.WriteAllBytes(textBoxOutput.Text, yData);
}
}
MessageBox.Show("Done");
}
If it helps, the sample code I was given for C++ looks like:
BYTE data[] = {'1','2','3','4','5','6','7','8'};
int type = 100;
int bufsize = (sizeof(data)+8) & ~7;
PBYTE pBuf = new BYTE[bufsize];
memcpy(pBuf,(LPCSTR)data, sizeof(data));
ABCdecrypt(type, pBuf, &bufsize);
delete pBuf;
And the reference document says the call should be:
<br />
ABCDecrypt(int type, LPBYTE data, int* datalength);<br />
If I'm not being clear, please ask me to clarify. Essentially, all I want to do is use the library to decrypt the file referred to by textBoxInput.Text and save it out as the file referred to by textBoxOutput.Text
|
|
|
|
|
Hi YttriumOxide,
Hi didn't notice that you've made a newer post of the same question so I've answered on the previous one. However, I notice one thing in this post that seems to differ from your previous one and which may well be the source of your problem.
The final parameter of ABCDecrypt is int* datalength but when you import the function from the DLL you specify the parameter as int datalength . Then when you call it you pass yData.Length which is an int, not an int*. Also, I see you import the second parameter ae byte* data . I'm not sure if makes any difference in C# but it might just make better sense to import it as byte[] data .
So I would think that you should import the function from the DLL as:
unsafe public static extern bool ABCdecrypt([MarshalAs(UnmanagedType.I4)] int type, byte[] data, ref int datalength);
And then, when you call it, it should look something like:
ABCdecrypt(100, yData, yData.Length);
I assume this function takes a byte array (data ) of length datalength and decrpyts it according to some algorithm specified by type . It then writes the result into data again and updates the datalength value also. This would suggest to me that the returned byte array may be of a different size than the input byte array. If this is the case, you need to make sure that the size of yData is big enough to hold the returned byte array.
If you know that the returned byte array will never be bigger than 256 bytes, you could do the following:
byte[] myBuffer = new byte[256];<br />
byte[] yData = File.ReadAllBytes(textBoxInput.Text);<br />
int DataLen = yData.Length;<br />
<br />
Array.Copy(yData, 0, myBuffer, 0, DataLen);<br />
ABCdecrypt(100, myBuffer, ref DataLen);
At this point, myBuffer should contain DataLen bytes which represents the returned byte array.
There may very well be more elegant sollutions but I am not very strong in C#. Most of what I wrote here came from the C++ programmer in me;)
|
|
|
|
|
Hi Dewald,
Okay, now I REALLY feel like an idiot for missing that one - I guess it's just one of those things that it helps when another pair of eyes looks at it.
I haven't got a chance to try it out now, but I'm 99% certain that you've just solved my problem, so thankyou very much
As a note, I generally code C++ as well (albeit, not brilliantly yet), as I'm mostly a Linux coder and I'm just forced in to C# on Windows at work.
|
|
|
|
|
Is there a way I can place a user control onto a form in designer mode without having to have it go into the GAC? The tutorials out there seem to indicate this is the only way to get it into your toolbox.
Regards,
James
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
If I understand you correctly, this may solve your problem. This is how I did it on a project I'm currently working on.
Show your toolbox in VS. Right click on the toolbox, and select the Choose Items... menu option.
A dialog now shows that is titled "Choose Toolbox Items". Click browse, find the DLL or EXE your user control is in, and click OK.
The list that is under the .NET Framework Components tab should now list all User Controls that DLL or EXE contained. Make sure that the checkbox next to the user control you want to put on your form is checked, then click OK. The "Choose Toolbox Items" dialog goes away, and your User Control is added to the currently selected tab in your toolbox (doesn't look like a tab, but that is what the context menu calls them)
You should now be able to drop that user control on your form.
BTW, I use VS2005, so I'm not sure if its the same for VS2003.
HTH.
|
|
|
|
|
hi
i want to hide one or more row of datagridview that bind to dataset, but the following error shown me :
Row associated with the currency manager's position cannot be made invisible
how to solve this problem ?
|
|
|
|
|
How can |I get a lighter tone of a particular color. Like if I have a value of color in rgb wht changes I have to make to it to make the same color with the lighter tone......
|
|
|
|
|
Take a look at Christian Graus articles on C# Image Processing with GDI+
that should help.
led mike
|
|
|
|