|
I need a control similar to the Property Grid, but that I can use without an object. I would like to set my own "properties" with code and be able to retrieve what the user entered.
Short of writing my own (which I don't have time, this is an urgent project), does anybody have an idea??
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
You could use the Reflection.Emit API to create classes at runtime.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
James T. Johnson wrote:
You could use the Reflection.Emit API to create classes at runtime.
That sounds way too hard for a simple beginner like me! this is my first program in C#/.NET! But anyway, I'll take a look at it!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Yeah, its definately not for the faint of heart; I haven't looked at the emit classes yet either
But unless you create your own PropertyGrid to work with an array of values thats the only option I can think of to use the existing grid.
If you don't mind not getting the look and feel of the property grid you could use a DataTable and a DataGrid to let the user enter data. It really loses its effectivness if you have more than a few different items to enter because of all the scrolling involved.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Luis Alonso Ramos wrote:
Short of writing my own (which I don't have time, this is an urgent project), does anybody have an idea??
Hi, just write a simple Seetings Class, thats what I do!
public class Settings {
string name;
string password;
public string Name {get{return name;}set{name=value;}
public string Password {get{return password;}set{password=value;}
}
Then just seriallize to object to a stream and deserialize to open. Note if u change your classes properties, you cannot deserialize an "old" version of the class to a "new" version of the class. Alternatively, you can reflect all the properties to an XML file and read it from there (not too sure how to handle non-primative class there, still looking).
If you dont have time to do this, then you really dont have time
Hope this helps
READ MSDN
|
|
|
|
|
This sounds interesting... I now have a property grid with the object I want (more or less working)... In the object I have properties like "Name", "SubName", "Phone"... how can I make the control display "Commercial Name", "Branch Name" and "Phone Number" in the grid (not at the bottom in the help panel)???
Also, any way to set this at runtime (so I can get them from the resources for localization purposes)?
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Global Property Grid
This should help you out.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I'm currently taking a look at it... I think that will be it... Thanks!!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
I got it to work now... just two small problems:
1. The order of the properties... I tried setting NoSort (the docs say that the grid sorts them as returned by the properties collection) and added an Index attribute to each property... but how do I use the Index attribute to return properties in a certain order when enumerated??
2. Is there a way I can make of my properties display a multiline edit control???
Thanks!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Luis Alonso Ramos wrote:
2. Is there a way I can make of my properties display a multiline edit control???
The way that the TextBox control displays a multiline text string in the propertygrid is that it uses a string array (string[]) called Lines. If you want your object to do the same thing, just add a string[] property. Each line ( a line ends with an System.Enviroment.NewLine ) is an individual item in the array. If you add a string[] property and then when the object is shown in the propertygrid you can click your "Lines" property and there will be a little button with "..." on it. If you click the button it will popup a dialog that will allow you to type just like notepad.
You will then probably have to concatenate the strings in the array to make one "text" property...
Hope this helps for item 2. I am still looking into item 1.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thanks... I just looked at it... but I would have to customize the dialog box that pops up (language, caption of labels, and so on.) I think what I will do is use the description pane to ask the user to insert semicolons (or something else) to signal new lines, and replace them by new lines before saving the string.
Again, thank you very much!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Inside of my control that I built, I want some sort of function like OnFinishInit that will be called once the control is added to it's form.
Currently, when a particular property is set to true , then I add a collection property to a ArrayList.
Unfortunately, the collection property is below my boolean property, and the collection never gets added because the collection isn't built until after the boolean property is set.
So, I need to wait until all properties are loaded before I try to add these collections to the array.
Thoughts?
|
|
|
|
|
I think the System.ComponentModel.ISupportInitialize interface will give you what you want. Simply add that bit of code to the EndInit() method.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Perfect!!! Thanks for your help.
|
|
|
|
|
hello,
i'm trying to do a File.Copy but over the wire. more specifically an UpLoad, since it's starting from a Client machine.
Catch is this is via a WinForm/UserControl/ComponentModel object(s). so nothing to do with any kind of ASP, ASP.NET or otherwise. in the end i'm just trying to take a file of some type, be it a .jpg/.dll/.something and send/save it to a server over the net.
i've been experimenting with a number of classes; WebClient, HttpWebRequest and HtmlInputFile/HttpPostedFile. the last 2 being specific to ASP.NET, as i thought i might be able to make the system think it was coming from as ASP.NET page or something like that. i've been using a WebServer(IIS) for the connection, specifically to a Virtual Directory. which is where the file(s) will need to be in the end anyways. but i'm having no luck passing the file to the virtual file path.
any advice or help would be great.
Thank you,
Orion
|
|
|
|
|
|
sorry.., yes just simply transfering a file over the internet from my client to my server. Absolutely nothing to do with a web pages.
i'm sure i'm missing something obvious. although every example i look at is from web page to web page.
i am trying to put the file in C:\Inetpub\wwwroot\SomeDirectory, but again has nothing to do with web sites. these files are dll's and source code files.
Orion
|
|
|
|
|
1. Drop a ComboBox on a form.
2. Add 5 items to the ComboBox in the Form_Load event.
3. Run the project.
4. Pull down on the ComboBox.
5. While it is still pulled down click the mouse some
place else on the form.
6. Notice that the ComboBox still has focus even though
the pull down menu disappears.
7. Once again click the mouse some place else on the form.
8. Now the ComboBox loses focus.
I think this is a bug. Any suggestions or feed-back
welcome.
Thanks.
|
|
|
|
|
First time when u click on the form it just makes a selection from your ComboBox but the focus stays in there but on the second click, it loses focus.
I think this is the normal sequence.
|
|
|
|
|
Yes this is a standard feature. When the DropDown window is displayed it sets MousCapture. The intention is to prevent an accidental command from executing from an inadvertand mouseclick intended to close the dropdown window.
|
|
|
|
|
I've created a strongly typed dataset but whenever I try to select rows from
a table and try to cast the rows, I'm getting an error "Specified cast is
not valid.".
I have a table named "Inventory". I'm able to select rows and place them in
a variable with type DataRow[]. However, when I try to cast it to a
InventoryRow, I get errors every time.
Here's the code: my dataset name is PADS...
working code:
DataRow[] recordArray = this._dataSet.Inventory.Select();
error code:
<br />
PADS.InventoryRow[] recordArray =<br />
(PADS.InventoryRow[])this._dataSet.Inventory.Select();<br />
I'm certain I'm using the correct variable names because I'm able to easily
create new records with the following:
<br />
PADS.InventoryRow record = this._dataSet.Inventory.NewInventoryRow();<br />
this._dataSet.Inventory.AddInventoryRow(record);<br />
Any input would be greatly appreciated!
Andrew Connell, MCDBA
IM on MSN
andrew@aconnell.com
|
|
|
|
|
I've run into a problem like this before with a server i wrote. I couldn't find any elegant solution. Logic tells you that you should be able to make this class but for some reason it won't allow it. What I ended up doing was creating an Array of the more specific type ( PADS.InventoryRow ) and then manually putting every element from the array returned from select into the more sepcific array.
If you find an easier way to od that please post it.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Yikes!
That's something I definatley don't want to get into. I'd much rather deal with the native DataRow objects than manually add each item into the typed object. That seems like a TON of overhead. If I find anything I'll be sure to post it.
In the meantime, I'm investigating MAPPING and merging the two different types. If I can do that in my data access layer/components, and just continue on with the application development, then I'm fine with that.
Andrew Connell, MCDBA
IM on MSN
andrew@aconnell.com
|
|
|
|
|
I'm trying to develop my first C# app. I chose to develop a chat software because I wanted to use the sockets' classes.
I've develop a chat server and a chat client. In the last one, I have to display the incoming messages in a RichTextBox control.
The problem is that it doesn't automatically scroll to the end of this control when I append a text.
The piece of code is :
int index=dialogTextBox.TextLength;
dialogTextBox.AppendText(message+"\r\n");
dialogTextBox.Select(index, message.Length);
dialogTextBox.SelectionColor=myColor;
(NB : its append a new line using the 'myColor' color)
I tried to use the ScrollToCaret but it doesn't work.
Please help me !
jpeg
|
|
|
|
|
All you will need to do is...
int index=dialogTextBox.TextLength;
dialogTextBox.AppendText(message+"\r\n");
// Inserted here
dialogTextBox.Focus();
dialogTextBox.Select(index, message.Length);
dialogTextBox.SelectionColor=myColor;
// Focus your entry box back again here.
Or you can write an On Text Changed handler, like I had to that will focus the box, scroll to the caret, then focus back to the entry. You will have to do this if you are adding text to the box from a thread that you created to read from the socket like I did. Doh!
-Steven
|
|
|
|