|
First of all, thanks to all of you for your answe, I've resolved it using BindingList<t> instead of List<t>, now I've a problem of cross-threading but I'm gonna take care of it!
Thanks again
Paolo
|
|
|
|
|
ok, now that the problem has been fixed we've another one that came out, and for this I need your help at all!!!
This is the main form event :
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
myWorker = new Worker();<br />
dataGridView1.ReadOnly = false;<br />
<br />
dataGridView1.DataSource = myWorker.myList;<br />
<br />
Thread myThread = new Thread(new ThreadStart(myWorker.DoWork));<br />
<br />
myThread.Start();<br />
}
The Worker class is this one :
public class Worker<br />
{<br />
public BindingList<Product> myList = new BindingList<Product>();<br />
<br />
public void DoWork()<br />
{<br />
Random r = new Random();<br />
for(int i=0; i<1000; i++)<br />
{<br />
myList.Add(new Product("Test",r.Next(),r.Next()));<br />
Thread.Sleep(1000);<br />
}<br />
}<br />
}<br />
At the myList.Add(...) I get an exception of type "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
But this happen in a Business Object not in a Window's Control. I suppose this's because of the datagridview.Datasource property set, but how can I fix it?
Thanks in advance,
Bests
|
|
|
|
|
am writing an app that uses the .Net classes TCPClient and NetworkStream to read and write data between 2 machines. All works fine.
I have recently found a need to be able to send Http 1.1 with a SOAP message as the Http body. Currently i am using an XmlDocument to load and parse the SOAP data. However to do this i first have to read in the HTTP header, search for the beginning of the body and construct my own XmlDocument.
There must be a better way. I don't want to call a web service, i just want to send http with a soap body and receive the same.
I am looking for a means of loading in the NetworkStream into some kind of HTTP object to read the http stuff and also load the body into some simple Soap object that can be used to pull out/ set values.
Comments, Suggestions Welcomed.
Carl
|
|
|
|
|
|
That bad, huh?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I have one application that have one Mdi Form, and i would like to list all my open forms in a List View control.
Thanks.
Roberto
|
|
|
|
|
You will have to iterate through all of the form objects and if they are open, add them into the listbox.
Something like this:
foreach(Form childForm in MdiChildren) listBox1.Items.Add(childForm.Text);
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
It didn't work, but i think it would be something like that.
I'm gonna try more ways.
Thanks.
|
|
|
|
|
It should be something in that nature...My code was just a rough one, and it worked for me.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I have a Datagrid with Product details (productcode, ProductName, and Color). I have to make the color column as a combobox, that the user can select the color from the list. The problem I am facing is, I don't need all colors to the combobox, I need colors available for that particular product only. (ie combobox list should be dynamic as per the indivitual Item or individual row). Please Help mE, its Urgent.....
with regard s
Binu Varghese
Thanks in Advance..........
|
|
|
|
|
I have a button that launches a URL based on a text string provided to it.
I want that text to be linked to the column 6 of the row selected in my DataGridView. Basically, i want to know how can i use the current index of row and column.
Historically i have been using the text in a text box using the following syntax
private void toolStripLabelbutton1_Click(object sender, EventArgs e)<br />
{<br />
CommonFuncs.OpenURLSource(<br />
LinkGenerator.button1Source(this.textBox.Text));<br />
}
Any help is appreciated.
|
|
|
|
|
If you want to retrieve text of the cell at row i and at column j then you can use this:
datagridview1[j,i].Value where datagridview1 is the name of the datagridview. Note that the returned Value property returns object so you will need to convert it to string
|
|
|
|
|
What if, for row i in the datagridview1[j,i], I want row to be the row row selected or clicked?
|
|
|
|
|
I may be asking prematurely, without first doing the necessary homework, but I need to ask before I leave work, so I can really get stuck into the homework. I would like to present the same arrangement for colour options that Visual Studio uses in its Fonts and Colors options dialogue. I have some good resources on how to use ColorEditor, in a PropertyGrid and even externally, on its on a form. I'm just not sure if the material covers the actual color display used in the dropdowns.
I gather ColorEditor overrides a DropDown event, displaying the ColorEditor panel when the user clicks a drop down, but in PropertyGrid when not dropped down, only the colour name is displayed. I want one of those fancy dropdowns that shows the selected colour in the texbox area of the dropdown.
|
|
|
|
|
There's a custom pickers article somewhere on CP that illustrates this, but basically what you're saying is right, if you owner draw it you can fill it with a color.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I was actually looking for something to rip a control out of, but I suppose owner drawing a rectangle isn't that hard. It's not just filled with colour, it has a smaller rectangle filled with colour to the left of the actual colour name.
|
|
|
|
|
I posted this in the wrong forum, so here is a link to it:
http://www.codeproject.com/script/comments/forums.asp?forumid=1642&select=2300199&msg=2300199
|
|
|
|
|
I'm busy designing a custom grid that should be able to accommodate interleaved rows with varying column structures. I only need very lightweight functionality, so instead of extending a DataGridView, I'm creating my grid from scratch using a DataRowControl, which is a Panel with one Textbox for each column in the definition for a row. Then I arrange a collection of these DataRowControls vertically, one for each row in my data source, on another panel. Is there a better way to do this?
Now, when I do what I describe above, the first problem I find, and I'm sure you'll see many more posts on this here by me, is sizing. I don't want a scrollbar on each row, so my row Panel has AutoScroll set to false, but the Panel holding all the rows has AutoScroll = true. However, in this arrangement, I still only get vertical scrolling. Am I doing something wrong?
In summary, is my whole approach to this problem on the right track?
|
|
|
|
|
I am currently working on a project that involves previewing large amount of photoes at the same time, my program will have a view at which it will show the preview of all the image files in a particular directory. As of this moment, all the pictures are shown by using creating a PictureBox control for each picture and then shoving them into a panel.
I realize that the mem usage is huge after loading about 120 pictures of ~900kb in size. I am suspecting it is because each PictureBox has loaded the FULL image into the memory, but not the thumbnail.
I do realize that in the Image class, there is something called the getthumbnail() mehtod, how do i make use of this? Image is an abstract class, i cant use it directly, do i use some kind of file reader to open a stream and read it as an Image and then use the getthumbnail() method to get a thumbnail and then use it as the image for the pictureBoxes?
thank you for your help
|
|
|
|
|
Hi,
you can load an image in memory, make a thumbnail of the required size, and dispose of
the original image in memory:
public Bitmap GetThumb(string path, int wid, int hei) {
Image img=Image.FromFile(path);
Bitmap bm=new Bitmap(img, wid, hei);
img.Dispose();
return bm;
}
Remark: if wid and/or hei are much larger than 120 and the file does contain a thumbnail,
then the above provides better quality than a simple Image.GetThumbnailImage().
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello, maybe it's a stupid question, I had a form that before was shown as DialogBox with DialogBox.ShowDialog(); , now my boss want me to dock it on the right side of the main application, how can I do that?
Thanks in advance
Paolo
|
|
|
|
|
I think ShowDialog makes the form modal and as far as I know, you really can't dock a modal window.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I have not done this before, but AFAIK these are necessary steps:
- set Form.TopLevel false
- add the Form to its parent's Controls
I expect ShowDialog() is forbidden (conflicts with TopLevel=false) and
Show() is not necessary, since Form got demoted to a Control now.
You would want to play around with Location, Dock and/or Anchor properties.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks a lot,
how do I get the Main form control in order to do
dialog.parent = mainformcontrol ?
Thanks
|
|
|
|
|
There are several ways, I think I would go for this one:
have the main form perform all, i.e. create the dialog, reset toplevel,
add to its own Controls collection, take care of Location.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|