|
Nope, sorry, I haven't done any conversions to flash myself, I just gave you a hint
Regards,
Lev
|
|
|
|
|
Thanks all the same, Lev!
regards,
George
|
|
|
|
|
You're welcome
Regards,
Lev
|
|
|
|
|
How can i build a program that hv two classes (child class and parant class) child class is inheriting from parant class.
Now child class has two methods
1.which returns the name of parant class
2.which returns the object of parant class
|
|
|
|
|
Hi
you could use reflection. This would be in the child class.
<br />
public string GetParentClassName() {<br />
return this.GetType().BaseType.Name;<br />
}<br />
Hmm, the child itself is an object of the parent class. Don't know exactly what you mean with this.
Regards
Sebastian
|
|
|
|
|
I am not sure what do you mean by saying the Name and Object of parent class,
but you can get the Type of the base class like this:
public class Dad {
}
public class Kid : Dad {
public Type GetParentType() {
return this.GetType().BaseType;
}
}
Regards,
Lev
|
|
|
|
|
thanks...
thats what i want...
this was my 1st post on this site...
i really like this platform...
|
|
|
|
|
Hi
when you create a class that inherit from another class you must specify the base class type, this is the solution for your question.
class Base
{
public Base()
{
}
}
class Derieved : Base
{
public string GetPerentName()
{
return typeof(Base).Name;
}
public Base GetPerentObject()
{
return (Base)this;
}
}
|
|
|
|
|
I have a little server application that gives feedback to the user in two ways, one is to write entries to a log file and secondly by writing those same entries to a TextBox on the main form. The main form actually has very little other than this TextBo x.
This server could run for months on end so I would like to limit the total number of lines in this TextBox to, let's say 1000, but on a FIFO basis. With a ListBox it would have been fairly simple - doing something like this, every time I add text to the control:
while (listBox1.Items.Count > 1000)
listBox1.RemoveAt(0);
Is there an elegant way of doing the same with a TextBox ?
|
|
|
|
|
Somewhat awkward solution is to do it like this:
textBox1.Text = textBox1.Text.Substring(textBox1.Lines[0].Length + Environment.NewLine.Length);
This isn't very effective, so maybe someone will offer a better solution...
Regards,
Lev
|
|
|
|
|
Why would you use a TextBox at all? A ListBox is the right Control for showing unrelated lines of text, as in a logging application. A TextBox trying to give the same scrolling text result would be concatenating and removing text strings all the time.
And if you were to need some formatting (bold line, red line), make it DrawMode=UserDrawn...
|
|
|
|
|
You just stole the word from my mouth
Sometime I use ListView also, it gives some nice features like columns etc. in Detailed view
Regards,
Lev
|
|
|
|
|
Good point. I liked the idea of being able to select any number of rows and copy it into the clipboard but that's probably not sufficient reason to use TextBox rather than ListBox.
|
|
|
|
|
Dewald wrote: select any number of rows and copy it into the clipboard
that would take less than 10 lines of code to achieve in a ListBox: the selection is free (choose the right SelectionMode though), copying just requires some handler (e.g. a KeyDown handler recognizing CTRL/C) that concatenates the SelectedItems and copies them to the Clipboard.
|
|
|
|
|
Hi all,
i am having a data grid view control in my windows form, now i would like to add all rows of data that in dtSearchDetails that i got from here: dtSearchDetails = taSearchDetails.GetDeliveryDetails(id); into my data grid view
here is my code:
DeliveryDetails.tblSearchDeliveryDataTable dtSearchDetails = new DeliveryDetails.tblSearchDeliveryDataTable();using (DeliveryDetailsTableAdapters.tblDeliveryIdByDateTableAdapter taGetId = new DeliveryDetailsTableAdapters.tblDeliveryIdByDateTableAdapter())
{
int id = 0;
dtDetailsByDate = taGetId.GetIdByDate(dtpSearchByDate.Text);
using (DeliveryDetailsTableAdapters.tblSearchDeliveryTableAdapter taSearchDetails = new DeliveryDetailsTableAdapters.tblSearchDeliveryTableAdapter())
{
int n = dgvDeliveryDetails.Rows.Add();
for (int i = 0; i < dtDetailsByDate.Rows.Count; i++) //assume that dtDetailsByDate.Rows.Count = 3
{
id = Convert.ToInt32(dtDetailsByDate.Rows[i][dtDetailsByDate.IDColumn].ToString());
dtSearchDetails = taSearchDetails.GetDeliveryDetails(id);
foreach (DeliveryDetails.tblSearchDeliveryRow dr in dtSearchDetails)
{
dgvDeliveryDetails.Rows[n].Cells[0].Value = dtSearchDetails.Rows[i][dtSearchDetails.ClientCompanyColumn].ToString();
dgvDeliveryDetails.Rows[n].Cells[1].Value = dtSearchDetails.Rows[i][dtSearchDetails.DeliverDateColumn].ToString();
}
however, these codes are not working, the compiler says: there is no row at position 1, and it points to this statement: "dgvDeliveryDetails.Rows[n].Cells[0].Value = dtSearchDetails.Rows[i][dtSearchDetails.ClientCompanyColumn].ToString();"
Thanks heapls
Andie
|
|
|
|
|
Hi Andie,
you are iterating through the row count of dtDetailsByDate, but using the index i with the rows in dtSearchDetails. Are you sure that both tables have the same row count?
Regards
Sebastian
P.S.: If you post your code between <code></code> it is better to read.
|
|
|
|
|
no, they dont have the same row count, that's the problem i discovered, but dont konow how to fix it
|
|
|
|
|
Okay, so you could check if a row at index i exists before you try to access it. But I think there is a underlying problem. What should your code do exactly?
|
|
|
|
|
Hello,
i am developing a ASP.NET C# 'BACKUP' application. so here i have to display file and folders of computer in tree view, so that user can selected which they want to create a back up. but i am begineer to this platform. also i have searched many code for this but i am not getting it.
can any one provide me the code for this.
please it is very help full to me.
|
|
|
|
|
kavitaBC wrote: so here i have to display file and folders of computer in tree view
Files and folders of server or the client machine? If it is server, use Directory class and work with the methods provided. If it is client machine, ASP.NET can't do that.
BTW, this is C# forum, not ASP.NET.
|
|
|
|
|
You have to code a function that recursively scan a folder for files/folders and add it to the treeview.
You can start with
//this code shows a dialog to choose a folder
FolderBrowserDialog FBD = new FolderBrowserDialog();
FBD.ShowDialog();
string path = FBD.SelectedPath;
//with this you get files in the folder
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] filInfo;
filInfo = dirInfo.GetFiles("*.*");
DirectoryInfo subDir = dirInfo.GetDirectory();
Or Something like this. Hope it helps.
|
|
|
|
|
Hi guys,
I'm trying to make the listview to look exactly like the one in Windows Explorer on Vista.
I used the SetWindowTheme function from uxtheme to theme it, but I cant get rid of the focused border. I noticed that when the form that contains the listview lose focus there's no ugly dotted border. So is there any way to take away the focus from a single item in the listview?
Thanks in advance
Matteo
|
|
|
|
|
Hello,
i want to change a Property from a class to a specified Value. How can i do this over a function/method like
ChangeValue("MyProperty","Value");
i cannot change them over myClass.myProperty = Value, because everytimes the Property changes.
Many Thanks
|
|
|
|
|
This can be done using reflection:
Type myType = myObject.GetType();
System.Reflection.PropertyInfo myProperty = myType.GetProperty("MyProperty");
myProperty.SetValue(myObject, "Value", null);
For reference: MSDN[^]
|
|
|
|
|
hi,
many thanks, but i got one problem, if i want to change a location, or a color-value or something else like (myObj.Location.x) i get a NullReference-Exception.
So i tried it with
Point myPoint = myObj.Location;
....
System.Reflection.PropertyInfo myProperty = myType.GetProperty("X");
myProperty.SetValue(myObject,20,null);
but of course, the button doesn't change.
How can i solve this Problem?
|
|
|
|