|
Hi Mike, thanks for your reply.
So, as my situation is just only reading connection string and no writing or editing, so I dont need to worry about Locking. RIGHT ?
Thanks and regards,
Emran
|
|
|
|
|
|
hi everybody,
i was given a job of developing a function which accepts 3 parameters i.e., an assembly path, a class with namespace, and a method in that assembly. the function should return the value that is being returned by the method that iam invoking(the one which we passed as a parameter)
iam using system.reflection namespace.
the problem is, i also need to pass arguements to the method that iam invoking but it is just not working the i way i want. this is how iam calling my function ..
public int myreflect("..the path of the assembly..", "...calss name with namespace..say N.C1..","..method name..say M1..", 2,4) // 2,4 are the arguments iam passing to my method M1//
this is how iam defining my function
public int myreflect(string a, string b, string c, params int[] list)
everything is working except that i need to somehow extract the arguements which are in the param array i.e., list.
i need to capture those arguments and store them in another array..say int[] args..and use this args in Invokemember function, as parameters to invoke my M1 method. i hope i have done a fair job in explaining my problem. a little help would be greatly appreciated. Thanks in advance....
Sonu
|
|
|
|
|
As InvokeMember takes an object array, copy the content of the integer array into such an array and then pass it to InvokeMember .
object[] args = new object[list.Length];
list.CopyTo(args, 0);
"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
|
|
|
|
|
Thanx Stefan!!
this is exactly what i wanted.
iam gratefulto you....thanx once again..
Sonu
|
|
|
|
|
Hi
How can I have Windows open a file using the default program? eg. ".txt" files open with notepad, etc.
Thanks (The function's at the back of my head somewhere, but I just can't find it... )
|
|
|
|
|
thepersonof wrote: The function's at the back of my head somewhere, but I just can't find it...
Look for the brain cell labeled Process.Start and you found it
"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
|
|
|
|
|
|
Hi
I'm just wondering why I can't use the PropertyInfo class to set the value of a property if I'm using the implicit conversion operator?
How do I get around this problem? I want to use the PropertyInfo.SetValue function, but I need it to work with all datatypes.
Thanks
/mj
==========================================================
Guid oId = new Guid();
MyGuid oMyId = new MyGuid();
MyClass oClass = new MyClass();
PropertyInfo oInfo = oClass.GetType().GetProperty("Id");
oClass.Id = oMyId; // fine...
oClass.Id = oId; // this works fine!
oInfo.SetValue(oClass, oMyId, null); // this is also fine
oInfo.SetValue(oClass, oId, null); // but this doesn't work!!?
==========================================================
These are my classes
==========================================================
public class MyClass
{
private MyGuid m_oId;
public MyGuid Id
{
get { return m_oId; }
set { m_oId = value; }
}
}
public class MyGuid
{
public MyGuid()
{
m_oId = new Guid();
}
public MyGuid(string p_sId)
{
m_oId = new Guid(p_sId);
}
public MyGuid(Guid p_oId)
{
m_oId = p_oId;
}
private Guid m_oId;
public static implicit operator string(MyGuid p_oId)
{
return p_oId.m_oId.ToString();
}
public static implicit operator MyGuid(string p_sId)
{
return new MyGuid(p_sId);
}
public static implicit operator Guid(MyGuid p_oId)
{
return p_oId.m_oId;
}
public static implicit operator MyGuid(Guid p_oId)
{
return new MyGuid(p_oId);
}
}
|
|
|
|
|
hi
What event is fired when the exit ("X") button of a form is clicked (but before the form closes)?
thank you for your help
|
|
|
|
|
Form.Closing or Form.FormClosing in .NET 2.0 respectively.
"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
|
|
|
|
|
|
Can anyone tell me how to "deeply" refresh property grid. That means after refreshing it all attributes attached to its SelectedObject's properties will be reloaded.
I have tried the following:
1. propertyGrid.Refresh(); // Doesn't work
2. propertyGrid.SelectedObject = PropertyGrid.SelectedObject; // Doesn't work
3. object obj = propertyGrid.SelectedObject;
propertyGrid.SelectedObject = null;
propertyGrid.SelectedObject = obj; // Doesn't work.
I try also to assign a new object (of the same type that was assigned to the propertyGrid) to another property grid but the second property grid still displayed the cached attributes.
It seems that the .net framework cache the attributes assigned to the selected object, but how can i clear that cache - or at least make the framework reloads these attributes.
The reason i want to do so is to enable runtime switching between different languages. My overriden Description, Category And DisplayName attributes loads values depends on the current thread culure UI.
Any suggestions?
Thanks
|
|
|
|
|
Dear Friends
I've bound the DataGridViewComboBoxColumn to a table in Database, and I want programmatically to change the index of the selected item in the DataGridViewComboBoxCell, and I didn't find any property to do that
kindly help me to do this...
|
|
|
|
|
Hello
Your title was about assigning values. This means True or false valus to the cells. This is done simply by changing the DataGridViewCheckBoxCell.Value property to either true or false.
OTOH in your post you said you want to change the index!! this is considered more with rows not columns. If you want to change the display index of a row -Move it up or down in the grid-:
DataGridViewRow MyTempRow = MyDataGridView.Rows[OldIndex];
MyDataGridView.Rows.RemoveAt(OldIndex);
MyDataGridView.Rows.Insert(NewIndex, MyTempRow);
PS.I used OldIndex/NewIndex naming conventions just for the sake of clarity. If you want to get the first selected row use MyDataGridView.SelectedRows[0], provided that you check it is not null first.
Regards
|
|
|
|
|
1] Is there any method of load form2 from form1?
2] Is case of resize form1 ,when a form1 is loaded textbox size is equal to form1 size & when i hide the status bar this resize statement is work but at loaded time its not work what is reasion behind it?
e.g.
//above code is not work properly
private void Form1_Load(object sender, EventArgs e)
{
//toolStripStatusLabel1.Text = "© 2006,Microsoft Corporation,All Rights Reserved";
textBox1.Font = new Font("Arial",16,FontStyle.Bold);
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 80));
}
//above code is work properly
private void statusBarToolStripMenuItem_Click(object sender, EventArgs e)
{
if (statusflag == false)
{
statusBarToolStripMenuItem.Checked = true;
statusStrip1.Visible = true;
statusflag = true;
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 80));
}
else
{
statusBarToolStripMenuItem.Checked = false;
statusStrip1.Visible = false;
statusflag = false;
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 60));
}
}
desert_rose
|
|
|
|
|
Stateless wrote: 1] Is there any method of load form2 from form1?
A form is just a class. You just instantiate the class and call the apropriate methods on it.
MyForm frm = new MyForm();
frm.Show();
Stateless wrote: Is case of resize form1 ,when a form1 is loaded textbox size is equal to form1 size & when i hide the status bar this resize statement is work but at loaded time its not work what is reasion behind it?
Why don't you just use the Dock[^] property on the text box to get it to fill the window by setting it to DockStyle.Fill . Then you don't have to worry about that because it will resize itself automatically.
Stateless wrote: //toolStripStatusLabel1.Text = "© 2006,Microsoft Corporation,All Rights Reserved";
I'm really curious about that line. Why were you thinking of assigning the copyright of your applicaiton to Microsoft?
|
|
|
|
|
Is there any method which will compare two strings and returns the difference between both strings ?
eg. string str1 = "123";
string str2 = "12345";
in this case result should be "45".
|
|
|
|
|
Hi,
You can use -
string result = str2.Replace(str1,"")
<marquee>"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
i'm trying to connect to the SQL Server. the problem is that im not connecting to an existing database. i'm trying to connect to the server so that i can execute queries and create a database programmatically. so if any one can help then i'll be waiting.
i'm attaching the connection string that i'm using
ConnectionString="Integrated Security=SSPI;"+"Initial catalog=;"+"Data Source=localhost";
i've not used Username and password 'cause im not using any server authenticaion. I'm using the windows authentication. should i include the username and password of the windows authentication??
Saira
|
|
|
|
|
As far as I know, you cannot connect to SQL Server without connecting to any database. So try to fill the Initial catalog (for example, master database).
If that does not help, please post the error message you receive.
|
|
|
|
|
Hello
Chopeen is right! You should connect to master database if you want to connect directly to the database, or any other INFORMATION_SCHEMA if you want to get info about existing databases. Yet, I must remind you not to edit/add/remove anything to the master database or any other default database. This is considered dangerous and inappropriate.
Regards
|
|
|
|
|
Hi
You can connect to a SQLServer without specifing any Database.Just skip the Initial Catalog part and every thing will be fine.
If you are using windows authentication you should not include user name and password(That's why we use windows authentication )
Best regards
Nima
|
|
|
|
|
well nima i've already tried this approach but it still doesn't work
could this problem be solved after i use MSDE? i'm not using it right now.
anyway thanks for your reply.
regards
saira
|
|
|
|
|
Hi
You should omit the whole part (there should be no Initial Catalog in your connection string) something like :
<br />
string connectionString="Data Source=.;user=sa;pwd=sa";<br />
That's it.
I'm not sure about MSDE I've used this on SQL Server 2000 and It's working fine (but I didn't check it using windows authentication)
Try connecting to your server using Visual Studio Server Exlorer and don't enter any database then take a look at its connection string.(It seems that using this way a connection to default database is established)
|
|
|
|