|
Where exactly is the problem? Is is that you are not able to resolve the row/column from the mouse position? If yes than have a loog at the HitTest function of the DataGrid.
|
|
|
|
|
thanks, that's right.
i cannot get the icon into the row. I tried the hittest function but i did not find any samples to see how to code it. Since I'm a student to pogramming, i don't know many things...
_______________________________________________________________
The only true wisdom is in knowing you know nothing. - Socrates
|
|
|
|
|
Basically you have to implement your own DataGridColumnStyle. It defines how columns are rendered and edited. This article[^] might be of help for you.
|
|
|
|
|
Hi how can i write all the values of ArrayList into a text box. i.e one object on each line of textBox
Regards
|
|
|
|
|
If you want one value on each line would a listbox be a better choice?
|
|
|
|
|
well i ve to write this in a textbox u can say that its a requirement.. now m using textBox.Lines statement to assign the values from an array of strings but this doesnt work with arraylist.......
so how can i do that ??
Regards
|
|
|
|
|
I.e like this:
ArrayList myList = new ArrayList();
fillArrayList(this.myList);
string [] listAsString = new string [myList.Count];
for(int i = 0; i < myList.Count; i++)
listAsString [i] = myList[i].ToString();
textBox.Lines = listAsString ;
-Larantz-
|
|
|
|
|
I would recommend listbox aswell because a listbox is dynamic, so if your ArrayList containts 10 or 100 items, it won't matter. A textbox will be filled up and you'd have to resize it manually to fit the contents.
ListBox foo = new ListBox();
ArrayList bar = new ArrayList();
fillArrayList(bar);
foreach(object obj in bar)
foo.Items.Add(obj);
If you know the objecttype in the ArrayList you can cast it like: "foo.Items.Add((myObject)obj);"
But unless the object has a ToString() method that produces something intelligent, the text added to your textbox will only be the type of the object. Like if you added a custom object called myObject, thats within the namespace myNamespace, the text you'd see in the listbox pr item would be "myNamespace.myObject".
If the ArrayList is filled with string-items you could use "foo.Items.Add(obj.ToString());"
-Larantz-
|
|
|
|
|
Thxx sir i ll try to use this
Regards,
|
|
|
|
|
Thx Sir, i have used list box as u have advised but the problem now is that i am actually displaying a file list from a folder wich is browsed by the user. so when the user browses for the next time the previous files also get displayed with it ..
and i didnt find any property to reset the listBox so wat will be its solution
Regards
|
|
|
|
|
|
how easy it was and i just kept on looking in the methods and properties of listBox
anyways thanks its working fine
Regards
|
|
|
|
|
I am trying to see if an Item already exists in a list view so I tried the following:
if (!lvDisk.Items.ContainsKey(fi[i].ToString()))
{
ListViewItem lvItem = new ListViewItem(fi[i].ToString());
lvItem.SubItems.Add("New");
lvItem.SubItems.Add(fi[i].LastAccessTime.ToShortDateString());
lvCD_DVD.Items.Add(lvItem);
}
else
{
ListViewItem lvItem = new ListViewItem(fi[i].ToString());
lvItem.SubItems.Add(fi[i].LastAccessTime.ToShortDateString());
lvItem.SubItems.Add("Already Exists");
lvCD_DVD.Items.Add(lvItem);
}
But I would always get the NEW status, so I tried to see what was going on. When I did a lvDisk.Items.GetType() I got System.Windows.Form.ListView+ListViewItemsCollection.
Can any one help me with this problem?
|
|
|
|
|
How do you add the items to the listview?
like lvDisk.Items.Add(someObject);
or lvDisk.Items.Add(someObject.ToString());?
-Larantz-
|
|
|
|
|
Like this:
ListViewItem lvItem = new ListViewItem(fi[i].ToString());
lvItem.SubItems.Add(fi[i].LastAccessTime.ToShortDateString());
lvDisk.Items.Add(lvItem);
|
|
|
|
|
Dear Friends,
assume the following namespace:
namespace MyNameSpace
{
public struct MyStruct
{
private int intVar;
public int IntVar
{
get { return intVar; }
set { intVar = value; }
}
}
public class MyClass
{
private MyStruct structVar;
public MyStruct StructVar
{
get { return structVar; }
set { structVar = value; }
}
public MyClass()
{
}
}
}
}
This class is in a dll file (MyAssembly.dll).I wanna load this dll at runtime by reflection and change the IntVar property of StructVar of my class instance by SetValue method of PropertyInfo class.
namespace MyApplication
{
public class MainClass
{
public void ChangeProperty()
{
Assembly asm = Assembly.LoadFrom("MyAssembly.dll");
Type t = asm.GetType("MyNamespace.MyClass");
PropertyInfo pInfo = t.GetProperty("StructVar");
<font color="red">
</font>
pInfo.SetValue(???);
}
}
}
Note that this class is in a seperate dll.
Best Regards.
[ _ Always there is another way _ ]
|
|
|
|
|
First create an instance of your class using Activator . Then you should be able to access your structure as usual.
Example:
<br />
Type t = asm.GetType("MyNamespace.MyClass");<br />
MyNamespace.MyClass cls = Activator.CreateInstance(t);<br />
cls.StructVar.IntVar = 4;<br />
|
|
|
|
|
Deart Rudy.
Thanx for your attention.But MyNamespace.MyClass is in a separate dll file and I haven't it at compile time.If I write this code I will receive the following error :
The type or namespace name 'MyNamespace' could not be found (are you missing a using directive or an assembly reference?)
Everything is at Runtime
[ _ Always there is another way _ ]
|
|
|
|
|
This should do the trick:
Assembly asm = Assembly.LoadFrom("MyAssembly.dll");
Type t = asm.GetType("MyNamespace.MyClass");
Object obj = Activator.CreateInstance(t);
PropertyInfo pInfo = t.GetProperty("StructVar");
PropertyInfo pInfo2 = pInfo.PropertyType.GetProperty("IntVar");
pInfo2.SetValue(1, pInfo.GetValue(obj, null), null);
"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
-- modified at 13:33 Sunday 7th May, 2006
|
|
|
|
|
Stefan Troschütz wrote: pInfo2.SetValue(1, pInfo.GetValue(obj, null), null);
That won't work, pInfo.GetValue(...) will return a boxed instance of the struct, so setting it's IntVar property won't affect the original struct. As I suggested in my post below, you can call pInfo.SetValue to set the new struct, but I wonder if there's a better way? Maybe an API function to get the struct by reference? Or is this what the compiler does when you call myClass.StructVar.IntVar = 2 ?
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Ups, I didn't thought so far and the code snippet was a quick, untested shot Thanks for the correction.
Currently no solution comes to my mind, that's better than yours. Would be interesting to dig a bit deeper into this, when having more time than now.
"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
|
|
|
|
|
You simply have to call GetProperty again for IntVar, this time on pInfo.PropertyType . That will get you a reference to IntVar's property info, which you can then use to call SetValue. Just remember to call SetValue on pInfo again, as the struct instance you have is a boxed instance and setting it's member values will not affect the original struct.
object o = Activator.CreateInstance(typeof(MyClass));
PropertyInfo structPropertyInfo = typeof(MyClass).GetProperty("StructVar");
object s = structPropertyInfo.GetValue(o, null);
PropertyInfo intPropertyInfo = structPropertyInfo.PropertyType.GetProperty("IntVar");
intPropertyInfo.SetValue(s, 2, null);
structPropertyInfo.SetValue(o, s, null);
MyClass a = (MyClass)o;
Console.WriteLine(a.StructVar.IntVar);
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Dear Senthil !
Thanx for your fast reply.The solution you provided worked properly.
King Regards,
Amir.
[ _ Always there is another way _ ]
|
|
|
|
|
i've create a simple access database with a table:
ID (int counter *)
Name (string *)
Surname (string)
Age (int)
Memo (memo)
why if i do this:
...
conn.Open();
OleDbDataAdapter oleDa = new OleDbDataAdapter("Select * from myTable", conn);
OleDbCommand cmdInsert = new OleDbCommand();
cmdInsert.CommandText = "Insert into TableNotes (Name, Memo) Values (?,?)";
cmdInsert.Connection = conn;
cmdInsert.Parameters.Add(new OleDbParameter("Name", OleDbType.VarChar, 20));
cmdInsert.Parameters.Add(new OleDbParameter("Memo", OleDbType.WChar));
cmdInsert.Parameters[0].Value = Name;
cmdInsert.Parameters[1].Value = textBox1.Text;
oleDa.InsertCommand = cmdInsert;
cmdInsert.ExecuteNonQuery();
i get error in "insert into query"? if i try to insert just Name it works!
|
|
|
|
|
try to change the name of the column Memo to something else, because may be it is conflicting with the keyword for creating Memo type column, once i have a column name DateTime and it was not functioning as well, when in changed the name to scheduledDateTime it worked.
Regards
Shajeel
|
|
|
|