|
|
I know how to draw a line and I have that code, I don´t know how to get a rectangle or some other form to show on a picture box.
|
|
|
|
|
how can i show a caret inside the listbox, perhaps a horinontally in between the listbox items.
|
|
|
|
|
netJP12L wrote: perhaps a horinontally
WTF! Stop making up words please. It's urgent.
led mike
|
|
|
|
|
dude...you got to take it easy. Where do you see the Urgent.
|
|
|
|
|
You can't with the standard ListBox. Google for editable listbox c#[^] and you're bound to find something.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I found nothing....they are telling how can you make an editable listbox. I am controlling the listbox paint method but couldn't find the right direction how to add a caret.
Is that even possible with listview.
|
|
|
|
|
why else would you want a caret except to show the current text insertion point i.e an editable listbox?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I want to add item depending on the caret position. for instance if the caret is under the 2nd listitem then I would just let user to add item under it if caret is under the 3rd item then user can add listbox item under it
|
|
|
|
|
I'm looking for a way to make it possible for the user to move a control on the form (or let's say inside a panel) during runtime by clicking and dragging with the mouse. Also, I'd like for the user to be able to resize the control by clicking on the edges and dragging.
Could someone point me to an article on how to do this perhaps or even explain the key principles in this thread please?
I suppose it's almost like creating a runtime form editor but I have no need to add controls at runtime. I just want to be able to resize and move one control that will already be on the form.
|
|
|
|
|
I think you'll need to capture mouse down, mouse move and mouse up events on the controls and set their Location or Size properties accordingly. To display handles on them you'll need to override their OnPaint methods.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
For resize controls, u can change the size of control:
control.height = x
control.weight = y
& for move its, u can change the location of its:
control.left = X
control.top = Y
u must write these code to event that u want (for example mouse click btn)...
|
|
|
|
|
I guess the this user wants to know how can he display handles around the control
|
|
|
|
|
I created a simple search in Google and I found this[^] for resizing and this[^] for dragging in less than a minute. Always try Google, MSDN and CP articles first, they're more and more and even more faster. Maybe you should visit here[^] before you post your post here[^]
|
|
|
|
|
I have a program that I didn't write, but maintain. Recently the assembly version was incremented to 1.0.1.0 and when it tries to load serialized objects (binary formatter) that were made with 1.0.0.0 I get an InvalidCastException. There was nothing changed in these on the objects themselves so there should be really need to be a cast.
|
|
|
|
|
|
Thanks for the reply.
Because there was no actual change in the class (just version) I was able to just change the Version number listed in the binary file to the new version and it cast fine from there on out.
|
|
|
|
|
I have a window manager class. It maintains references to open User and Item forms:
At the top I create an array list:
private static ArrayList oWindows = new ArrayList();
The I have a method to return an instance of a form in the collection:
public void GetOpenForm(FormTypes type, int iRecordKey)
{
form oRetVal = null;
foreach(form oForm in oWindows)
{
if (oForm.iRecordKey == iRecordKey)
{
}
}
}
Problem is, the references to oForm in the code above are not User or Item forms, so the iRecordkey reference fails to compile. Add to this, the Item and User forms are not based off any single base form.
How do I make oForm "know" about iRecordKey?
Everything makes sense in someone's mind
|
|
|
|
|
You need to cast the Object in the list to the appropriate type.
Why not use a typesafe container like List(T)[^] instead?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How do I know what type to cast it to? I would have to have a CASE: statement for each potential type I might need to use.
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: I would have to have a CASE: statement for each potential type I might need to use.
Sure, why not? Makes sense to someone.
led mike
|
|
|
|
|
hmm...if you don't know the types of objects in your
collection, how is the compiler supposed to know?
If you're mixing object types in the collection then you don't
have a lot of choice.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So! I finally am getting into more and more C#/.NET development, I am wondering if the following is possible using reflection and some other .NET-fu that I now nothing about (yet).
Here is what I am thinking... Presume I have several streams of CSV data that I want to convert into object form. While it is possible to parse the CSV and manually assign properties for each value, I have to write specific code for each object and (expected) stream format that I want to process.
I am wondering if this code can be generic so that I can just pass in the CSV stream, an object, and a set of properties that are on that object, and the code can extract the values, and use reflection (or something) to get at the property by its name, and set the value. Something like this:
String sCSVString = "<code>Value1,ValueABC</code>,Value2,<code>ValueXYZ</code>";
-----------------------------
AssignPropertiesFromCSV( sCSVString, objMyObject, "Prop1", "Prop2", null, "Prop4" );
Where the result would be that objMyObject would have Prop1 , Prop2 and Prop4 set to Value1, ValueABC and ValueXYZ respectively, skipping over the Prop3 property due to the null parameter passed in.
Is it possible to use reflection to dynamically examine objMyObject to find out if it has a Prop1 property, and then set it to a value?
My guess is that some ORM frameworks may work this way, but I have yet to delve into them and wanted to get a feel for it from the more C#-experienced devs here first.
While examples are not required, they are welcome. I just want to know if this is worth looking into or not.
Thanks!
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If the object is created based on the info in the CSV-file, you could implement ISerializable interface, which allows you to control the serialization and deserialization.
If you only want to set the values of an existing object based on CSV input, I would create a method on each class (based on an interface) which sets the properties for the class and understands the input paranmeter (CSV string). The input string would be easiest to handle using String.Split-method.
In both cases you wouldn't need to use reflection.
If you want to use reflection, you would have a method with two (csv+object) mandatory parameters and a third one as parameter array, for properties list. In this case you would examine the type of the object and then find each property's PropertyInfo given in a parameter using object type's GetProperty method. After that you can use the SetValue method for the PropertyInfo t set the value of the property (just check that the property is writable).
Hope this helps,
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Try this
void AssignPropertiesFromCSV(string csv, object obj, params string[] propertyNames) {
string[] csvValues = csv.Split(',');
int index = 0;
foreach (string propertyName in propertyNames) {
if (!string.IsNullOrEmpty(propertyName))
obj.GetType().GetProperty(propertyName).SetValue(obj, csvValues[index], null);
index++;
}
}
|
|
|
|