|
Thanks.Whether the breakpoint can be placed into the class given by .NET Framework.Such as:
protected CollectionBase()
{
this.list = new ArrayList();
}
The CollectionBase is a class given by .NET,Can a breakpoiint be placed in here? though the Microsoft is forbidden!
|
|
|
|
|
wanlim0817 wrote: Thanks.Whether the breakpoint can be placed into the class given by .NET Framework.Such as:
protected CollectionBase()
{
this.list = new ArrayList();
}
The CollectionBase is a class given by .NET,Can a breakpoiint be placed in here? though the Microsoft is forbidden!
No. You can't debug step into the .NET framework classes because Microsoft doesn't supply the necessary files.
Are you trying to find a bug or do you just want to learn how the class works. Reflector is very good for finding the internal workings and understanding how things work in the .NET classes.
|
|
|
|
|
Hi Friends,
i want to move the record pointer of DataGridView using code in C#.
i m trying BindingMangerBase but the problem is this only passion of bmb changing but the record pointer of dgv is not moving.
:-Dthe same is working fine with VB.NET. this is a code of VB.NET
Public Class frmTest
Dim bmb As BindingManagerBase
Dim bs As New BindingSource
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connDB()
End Sub
Private Sub connDB()
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = D:\TEMP\TestADO\DB\db1.mdb;")
Dim da As New OleDbDataAdapter("Select * From tblAdd;", cn)
Dim dt As New DataTable
Dim ds As New DataSet
da.Fill(dt)
bs.DataSource = dt
dgv.DataSource = bs
bmb = BindingContext(bs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bmb.Position = 0
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bmb.Position = bmb.Position + 1
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
bmb.Position = bmb.Position - 1
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bmb.Position = bmb.Count - 1
End Sub
End Class
here is the code of C# which is not working fine
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.SqlClient;
namespace testBindings
{
public partial class Form1 : Form
{
private SqlConnection conn ;
private SqlDataAdapter da;
private DataSet ds;
public BindingSource bs;
public BindingManagerBase bmb;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection ("Data Source=myhome\\sqlexpress;Initial Catalog=ChickenPeoxX;Integrated Security=True");
da= new SqlDataAdapter ("select * from tblGroup;",conn );
ds= new DataSet ();
da.Fill(ds,"GROUP");
dgv.DataSource = ds.Tables[0];
bs = new BindingSource( );
bmb = BindingContext[bs];
bs.DataSource = ds.Tables[0];
}
private void button1_Click(object sender, EventArgs e)
{
bmb.Position = bmb.Position+ 1;
textBox1.Text = bmb.Position.ToString() ;
}
private void button2_Click(object sender, EventArgs e)
{
bmb.Position = bmb.Position-1;
textBox1.Text = bmb.Position.ToString();
}
}
}:(
please help me with this ...
thnX in Advance
Regards
Sonal
.::HuNTeR::.
|
|
|
|
|
I'm using the checkedIndices property of the checked listview control. when i iterate through it using the following line
for(int i=0; i<indices_count; i++)<br />
{<br />
int a = TableListBox.CheckedIndices[0];<br />
}
for every iteration of the for loop, i get a different value for a, but i am only accessing the value of index 0, and it should remain the same throughout the for loop.
why is it showing such abnormal behaviour???
|
|
|
|
|
if u try to get all checked value then try this....
for(int i=0 ; i < this.listView1.CheckedItems.Count ; i++ )
{
String tmp=this.listView1.CheckedItems[i].Text.ToString() ;
MessageBox.Show(tmp);
}
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Hello guys.
I'm stuck in one of the silliest problems anyone would ever imagine. Alright, my application is a password protected database application. I know!! I've already put the passwords of my application, and the database in an external file -not the main config. I got my reasons though-. Now I want to encrypt that external file to protect my passwords, and not to hardcode them in my program.
The funny thing is that I need a key, wich has to be the same in the Encrypting/Decrypting process. I don't want to hardcode that key -I know it's not the best practice-. Also I don't want to use the File.Encrypt() method, as it's easily broken -using the Decrypt ethod BTW-, and assumes that the user has NTFS.
I figured out an inconvenient way of maing the user's password, or my Assembly's GUID as that key.This is my last resort, but I'd really like to hear fresh ideas, as I'm out of!!
PS.
Currently I'm reading MSDN security section. Can you imagine how desperate I am now?
Regards
|
|
|
|
|
Poor thing!! but dont worry, im even stuck in a more stupid problem i cannt update the database im connected to!!
All generalizations are wrong, including this one!
|
|
|
|
|
The most used solution in cases like this is to store the Hash value of the password instead of the password itself. When a user tries to login, the program will compute the Hash code of the password provided by the user and compare it to the stored value.
This is very secure, especially if you use strong hashing algorithm like SHA1. The .NET Framework provides exhaustive support for hashing.
The only problem is that you no longer have the clear-text password. It might be a problem if the user forgets his password.
|
|
|
|
|
First, thank you for your reply.
I already applied that solution in the login password of the user. I now have some other sensitive data that I must encrypt in an external file. Where would I put the encryption key? That was my question -sorry if it wasn't clear the first time-.
Regards
|
|
|
|
|
I ran across the same problem. Since the application wasn't meant to be particularly secure, I just hard-coded the encryption key in the application, "hiding" it so that it doesn't seem a key but just an error message.
In other words, there is a fictitious error message, and I use that string to generate the key using a method with a name like PerformOperations, so that it does not seem encryption-related.
It's not very secure, but in my case it was enough.
|
|
|
|
|
Well. I guess I'd go for that if my time is cut short. Thanks for your time Dario.
Regards
|
|
|
|
|
Hi,
I'm doing some string wrapping calculation, and need graphics.MeasureString to calculate the width of each character.
One problem is, Graphics does not have constructor. How can I get or create Graphics object, if the wrapping calculation must be inside one class library, not inside a dialog?
Thanks so much for your help?
|
|
|
|
|
You can use TextRenderer.MeasureText() method instead.
Regards
|
|
|
|
|
yeah, but TextRenderer.MeasureText() takes IDeviceContext as argument, which he doesn't have.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
|
|
Thanks dnh. I was wondering why it got two without the voting guy telling me what's wrong. When you posted your reply I thought you were the guy and that's your reason -felt little frustrated at first:->, sorry!-. Now I wonder again.
See you on the forums.
Regards
|
|
|
|
|
|
Thank you for all of your replies.
I have tried to use TextRenderer.MeasureText(), it works fine..
But I still prefer using Graphics to Measure, I found that it is more accurate. Because I need to set some scaleing and measure unit in graphics.
The method I get the Graphics is, I create a Form, and then use Form.CreateGraphics(), seems a stupid method ^_^, but works finally.
|
|
|
|
|
I am stuck trying to get a P/Invoke correctly done to a 3rd party DLL.
The DLL is called DNA.DLL. I have other P/Invoke calls working to it, but this one just doesn't want to. The problem is that it returns a string via a buffer. Whatever I try to declare as buffer (ref string, out string, ref StringBuilder, out StringBuilder) ends up causing a System.AccessViolationException in .NET 2 (C#, VS 2005).
Here is the info I have about this call:
Delphi: function DNA_Param(param,value:pChar; value_size:integer):integer; stdcall;
VBasic6: Public Function DNA_Param(ByVal param As String, ByRef value As String, ByVal value_size As Integer) As Integer
C++: int __stdcall DNA_Param(char *param,char *value,int value_size);
Request to the DNA Client to return the <value> of the <param> parameter stored in the CDM on the user’s computer. <value> should be a buffer of 256 bytes or greater. <value_size> should indicate the size of buffer allocated. If DNA_Param returns “0”, then <value> will contain the value of the <param> from the CDM. If DNA_Param returns “1”, then a problem occurred with the DNA.DLL.
----
A VC++ (unmanaged) sample implementation:
char buffer[255];
DNA_Param("ACTIVATION_CODE",buffer,sizeof(buffer));
using the signature for DNA_Param shown above
----
A VB6 sample implementation:
Public Function DNA_Param(ByVal param As String, ByRef value As String, ByVal value_size As Integer) As Integer
Dim buffer As String
buffer = Space(value_size)
DNA_Param = DNA_Param_DLL(param, buffer, value_size)
value = NullString(buffer)
End Function
Private Function NullString(ByVal s As String)
Dim i As Integer
i = InStr(s, vbNullChar)
If i = 0 Then
NullString = ""
Else
NullString = Left(s, i - 1)
End If
End Function
Private Function Space(Size As Integer) As String
Dim returnString as String
Dim i As Integer
Dim upperBound As Integer
upperBound = Size - 1
For i = 0 to upperBound
returnString = returnString + " "
Next
return returnString
End Function
----
Can anyone please help me with this?
Thank you very much in advance,
Patrick Schmid
|
|
|
|
|
Try using StringBuilder instead of using ref StringBuilder .
If C++ declaration:
int __stdcall DNA_Param(char *param,char *value,int value_size);
Then C# would be:
[DllImport("Dna.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
int DNA_Param(StringBuilder param, StringBuilder value,int value_size);
Regards
|
|
|
|
|
THANKS! just StringBuilder did it!
I couldn't use your code as is, because it would return an empty string all the time.
However,
[DllImport("Dna.dll")]
int DNA_Param(string param, StringBuilder value,int value_size);
worked like a charm!
Thanks for giving me the saving hint!
Patrick
|
|
|
|
|
Hi!
I have a “Windows Application” type Visual Studio .NET 2005 solution. This project has one Windows Form, and a User Control. The Windwos Form has an instance of this User Control.
The User Control has a LinkLabelsList property, of type System.Collections.Generic.List <linklabel>.
public System.Collections.Generic.List <linklabel> LinkLabelsList
{
get { return (mv_linkLabelsList); }
set { mv_linkLabelList = value; }
}
In the Properties Grid of the User Control instance on the Windows Form, a browse button with “periods” ([...]) is visible against the LinkLabelsList property.
On clicking this “periods” button, the “Collection Editor” window opens up. Any number of “LinkLabel” entries can be added here in this “Collection Editor”.
When I am done with adding LinkLabels in the “Collection Editor”, I click the OK button in the “Collection Editor” dialog box, and it returns to the Windows Form editor. However, all the LinkLabel entries added, DISAPPEAR and it again shows an empty space instead of something like “(Collection)”.
How do I solve this problem?? How do I PERSIST THE ADDED ENTRIES for the property for the User Control, when it returns from the “Collection Editor”?
Your helps would be greatly appreciated.
Thanks,
Dinesh M Jayadevan
|
|
|
|
|
Is it possible (C# programatically) to see if the current user is an administrator-level user?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
|