|
Hey
Ok first a confession I have got a bit Giddy with GDI so like using it for lots of things as it is simple but effective. However last year I made a small image manipulation application in Borland C++. I would like to over the following months build quite a complex one using C#.
Now I know there is a picture box control but I would also like to allow the user to draw things such as simple 2D and 3D shapes etc - my question is this:
Is the picture box control flexible enough for this or would I be better making my own control (say a white background and then drawing on it as the user wishes using GDI) or is there a better built in control?
Thanks
Dan
**Edit - basically what I would like to be able to do is ask any pixel inside a control its colour and also to set its colour
-- modified at 16:15 Thursday 6th September, 2007
|
|
|
|
|
No,the picture box control is useless, handle your own paint event and draw your own image.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
DanB1983 wrote: **Edit - basically what I would like to be able to do is ask any pixel inside a control its colour and also to set its colour
Basically, you need to read my image processing articles to learn how to most efficiently do that, or you need to use the GetPixel method on the image class.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hi,
I have a sqlserver database table Students with 4colummns: [studentid], [studentname], [studentaddress], [studenttel].
i want to read all the records from this table, make textboxes and put the data into these textboxes.
can somebody help pls?
Djavid j
|
|
|
|
|
You mean to use textboxes set to multiline with all studentids in one textbox?
Or one textbox per value which would result in 4 textboxes multiplied with the amount of rows in your table.
Anyhow - you should use a SQL adapter to retrieve the dataset, and then iterate over the rows in the table to read the values and fill them into your textboxes.
-Larantz-
|
|
|
|
|
Unless you know for a fact that the amount of rows in the table will be of a managable size, you might end up with hundreds of textboxes. (4 textboxes multiplied with the amount of rows).
You can get the amount of rows through the DataSet.Tables[<table index here>].Rows.Count property.
You'd be better off showing the data through either 4 textboxes set to multiline, or even better 4 ListViews, or the best alternative being a DataGridView.
To loop through the rows and retrieve data you could do the following:
... in the method where you process your dataset data ...
DataTable table = yourDataSet.Tables[int tableindex];
int rowCounter = 0;
foreach(DataRow row in table.Rows)
{
foreach(DataColumn column in table.Columns)
{
TextBox textBox = CreateValueTextbox(
column.ColumnName + rowCounter,
row[column.ColumnName]);
this.Controls.Add(textBox);
rowCounter++;
}
}
...
private TextBox CreateValueTextbox(string textBoxName, string value)
{
TextBox textBox = new TextBox();
textBox.Name = textBoxName;
textBox.Text = value;
return textBox;
}
NB!
I haven't compiled this so I might have missed something
Hope some of it can be of help.
Best of luck!
-Larantz-
-- modified at 18:19 Thursday 6th September, 2007
Btw - there's no handling of the location of the textboxes, so you'd have to add that yourself.
As of now they'll be placed on top of eachother.
modified on Wednesday, January 16, 2008 10:20:29 AM
|
|
|
|
|
Larantz thanx it was great help
|
|
|
|
|
more of an ADO.NET question[^] you can draw the text boxes dynamically (not that hard if you have problems see: here[^] will show how to create buttons then you can change the controls to anything else)
|
|
|
|
|
I was create many web controls with LoadControl() and I put these inside panel when Page_Load(),
each control have UpdatePanel for change the content of that control,
but when the event generated by UpdatePanel occurs, the Control dont exists.
Any idea, thanks.
Pandacad, a beginer in programing world 
|
|
|
|
|
Odd question, I know. But I cannot find help with this anywhere. I need, upon right click of a datagrid, to be able to have a context menu pop up (which I know how to do) but within this context menu I want to include the Word Filter, then right next to that have a textbox which one can enter text into for filtering.
If you need an example, Microsoft Access uses this function. I have searched high and low for a solution to this and *any* suggestions or samples would be wonderful.
Thanks!
Aaron
|
|
|
|
|
Hi,
does any body know, how i can prevent that links are opened in new windows?
I want all links to be opened in the same window of my form with the webcontrol.
|
|
|
|
|
Use the navigating event, check the WebBrowserNavigatingEventArgs its .TargetFrameName to see if it match the main window or a subframe within it. If there is a name mismatch then you just set .Cancel=true; and it'll stop without loading the url...
|
|
|
|
|
Hi,
What i want to be able to do is compare two images.
eg: image == Properties.Resources.backupImage
But if i do this, since image is a System.Drawing.Image object, it will always be false. Any ideas how to do this?
Regards,
Gareth.
|
|
|
|
|
What is it exactly that you're trying to achieve. Do you really want to compare the content of the picture, as in .. 'find the seven differences' or do you want to compare the filesize, filename .. that sort of things.
|
|
|
|
|
Hi Gareth,
I think you better provide more contextual info before we try and answer this one...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The reason it's not working, I think, is because Properties.Resources.SomeImage will always return a newly constructed image. That's why (Properties.Resources.SomeImage != Properties.Resources.SomeImage)
You'll want to try something like this:
Image backupImage = Properties.Resources.backupImage;
bool equal = image == backupImage;
|
|
|
|
|
I've googled and can't find any solutions that work.
I have a class called People that has two public properties of type string - Firstname and Surname.
I have a second class PeopleCollection : ArrayList that is an ArrayList of People objects.
Using the IComparable interface and CompareTo methods on the People class I can successfully sort by either property by specifying .Firstname or .Surname in the CompareTo method.
What I need to be able to do is sort on both fields so if the PeopleCollection instance held this data:
item[0].Firstname = "Dave" | item[0].Surname = "Smith"
item[1].Firstname = "Dave" | item[1].Surname = "Jones"
item[2].Firstname = "Andrew" | item[2].Surname = "Jones"
item[3].Firstname = "Andrew" | item[3].Surname = "Zzz"
after sorting it would be:
item[0].Firstname = "Andrew" | item[0].Surname = "Jones"
item[1].Firstname = "Andrew" | item[1].Surname = "Zzz"
item[2].Firstname = "Dave" | item[2].Surname = "Jones"
item[3].Firstname = "Dave" | item[3].Surname = "Smith"
Both columns sorted with field1 (Firstname) having priority and field2 being 'subsorted'.
I'm sure this is posible using IComparer but I just can't figure it out!
Dave
|
|
|
|
|
Hi,
you need a CompareTo method that compares the first sorting property first;
if the result is zero (which means the first property is indecisive), compare the second,
etc. until you have a decision on the relative sort order.
So it could look like this:
int diff=People1.Firstname-People2.Firstname;
if (diff==0) diff=People1.Surname-People2.Surname;
if (diff==0) diff=....;
return diff;
[CORRECTION] the - operator is not appropriate for string compare;
use diff=string.Compare(People1.SomeProperty, People2.SomeProperty); instead;
remark: Compare() has overloads to control case sensitivity [/CORRECTION]
-- modified at 14:39 Thursday 6th September, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc, I can see how that may work. Getting this error message though:
Operator '-' cannot be applied to operands of type 'string' and 'string'
|
|
|
|
|
You don't want to use the '-' operator. You can compare string using String.Compare(str1, str2). This returns an integer that would give you proper sorting. You can ignore case if you want by using String.Compare(str1, str2, true).
So the code would be something like:
Int32 order = String.Compare(p1.FirstName, p2.FirstName, true);
if (0 == order)
order = String.Compare(p1.LastName, p2.LastName, true);
return order;
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
sorry, my mistake, it is OK for integer data; for strings what you can do is:
diff=String.Compare(string1, string2);
which also offers an optional "ignore-case" argument.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks I'd actually just figured it out.
int diff = string.Compare(this.Surname, tmpObj.Surname);
Works perfectly! I wish I'd asked about 8 hours ago when I started working on this :->
Dave
|
|
|
|
|
DaveyM69 wrote: I wish I'd asked about 8 hours ago
Well, it is OK to try and solve a problem yourself. Analyzing a problem,
trying different approaches, and searching effectively all are part
of the learning curve; of course if these don't bring the solution in a
reasonable amount of time, you should launch a question on a forum like this one.
And once you got a solution, reflect on why you did not find that by yourself and/or sooner.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi..
could someone plz help me out..
I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.
Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports.
Ive started creating the class for User but now how do i go about creating the rest?
|
|
|
|