|
Hi,
I have dataset that is bound to a DataGridView. In my DataSet I have column "name" (string) and column "sex" (int). So far so good.
My problem is:
Now I need to convert "sex" to a comboBox type with values 0-> male, 1->female.
any ideas?
tnx
|
|
|
|
|
Hi,
If you want to do it the hard way, you could choose to set VirtualMode[^] to true. And use a DataGridViewComboBoxColumn[^]. However then you have to manage your datastore manually and all other related functions (including drawing the datagridview). This offers a great deal of flexibility, but is rather complex (though the msdn does give a very nice example).
You could also try to replace the column from the datagridview with a DataGridViewComboBoxColumn, but I don't know how to link the dataset to your column then.
Greets,
basambora
|
|
|
|
|
I've created a DataGridViewComboBoxColumn named "cbx". Added 0->"male",1->"female" to it's items;
I've added the "cbx" to my GridView as "sexA" column and for each row I "sexA".value = "sex".value;
i used this line:
gridview.Rows[0].Cells["sexA"].value = gridview.Rows[0].Cells["sex"].value;
Just as a remainder, "sex" is int type and also the "cbx" value is int type.
thought the results should be to show the displaymember on "sexA" by the value of "sex" it doesn't show anything on "sexA". Although later on I can edit and select a new value to "sexA" but can't do that using code!
it's seems like it doesn't update the gridview.
I tried GridView.Refresh().
Any ideas?
tnx
|
|
|
|
|
Iam making a calculator and have this aproximation errors, when I use the Pi constant and make Sin(pi) the answers I got is 3,23108510433268E-15 when it should be zero. ¿Someone knows how to fix this?
|
|
|
|
|
Hi,
floating-point numbers and calculations have a finite precision, and they must balance between speed and accuracy. Transcendental numbers such as pi cannot be represented exactly. And the result of floating-point operations can also depend on the hardware used. I am getting 1.2E-16 for
double x=Math.PI;
double y=Math.Sin(x);
output("sin(pi)="+y);
on an Intel T8300.
If you are not satisfied by some function, you can try and improve it by:
- using a smaller range of it
- replacing it completely.
For periodic functions, reducing the range is the obvious first attempt;
you could rely on identities such as sin(pi-x)=sin(x) and sin(pi/2-x)=cos(x) to reduce all values of x to the interval [0, pi/4] for which one could hope the Math class gives the most accurate results.
|
|
|
|
|
As Luc said, floating point is not exact due to computers storing numbers in binary. You do realize that 3,23108510433268E-15 is pretty darn close to zero, right?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Paul Conrad wrote: As Luc said, floating point is not exact due to computers storing numbers in binary
I didn't say that at all. I did not even mention binary; if computers were to store things in decimal, their value for pi or SQRT(2) or any other transcendental or irrational number would be equally wrong.
Paul Conrad wrote: 3,23108510433268E-15 is pretty darn close to zero
That is a matter of opinion.
The integer number 323108510433268 is also pretty close to zero in that there are many more integers larger than it, than there are integers between it and zero...
|
|
|
|
|
Luc Pattyn wrote:
floating-point numbers and calculations have a finite precision
That is what I was meaning.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Paul Conrad wrote: You do realize that 3,23108510433268E-15 is pretty darn close to zero, right?
How can it be ? Look at all those numbers.... :P
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
That's what I was thinking!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Christian Graus wrote: Look at all those numbers....
3,23108510433268E-15 = 0.00000000000000323108510433268, close enough to zero for my line of work. If I were writing heavy duty scientific apps, then yes, that would be a completely different matter.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hello,
I'm trying to make a HTTP POST request in multipart/form-data to simulate the upload of a file to a web server.
But I've a problem, the class only send Headers and don't send data.
My query is like this :
[root@localhost rapha]# python server.py
IP : ('127.0.0.1', 32851)
POST / HTTP/1.1
User-Agent: FilesApi/FilesAPI v0.1 (Unix 2.6.27.7)
Referer: [url]http:
Content-Type: multipart/form-data; boundary=-------------------906641065
Content-Length: 1845
Expect: 100-continue
Connection: keep-alive
Host: 127.0.0.1
But normaly, it will be like this :
[root@localhost rapha]# python server.py
IP : ('127.0.0.1', 32851)
POST / HTTP/1.1
User-Agent: FilesApi/FilesAPI v0.1 (Unix 2.6.27.7)
Referer: [url]http:
Content-Type: multipart/form-data; boundary=-------------------906641065
Content-Length: 1845
Expect: 100-continue
Connection: keep-alive
Host: 127.0.0.1
-------------------906641065
Content-Disposition: form-data; name="fichier1"; filename="icon.png"
Content-Type: application/octet-stream
[I](contenu de l'image)[/I]
---------------------906641065Content-Disposition: form-data; name="nb_fichiers"
1
---------------------906641065
Content-Disposition: form-data; name="votes"
on
---------------------906641065--
My sources :
string Boundary = "-------------------" + (new System.Random()).Next();
string Data = Boundary + "\r\n";
int FichierNo = 0;
foreach(string Fichier in this.FilesList) {
FichierNo++;
System.IO.FileInfo FileInfos = new System.IO.FileInfo(Fichier);
Data += "Content-Disposition: form-data; name=\"fichier" + FichierNo + "\"; filename=\"" + FileInfos.Name + "\"\r\n";
Data += "Content-Type: application/octet-stream\r\n\r\n";
Data += (new System.IO.StreamReader(Fichier)).ReadToEnd()+ "\r\n";
Data += "--" + Boundary;
}
Data += "Content-Disposition: form-data; name=\"nb_fichiers\"\r\n\r\n";
Data += FichierNo + "\r\n";
Data += "--" + Boundary;
if(this.EnableVotes) {
Data += "\r\nContent-Disposition: form-data; name=\"votes\"\r\n\r\n";
Data += "on\r\n";
Data += "--" + Boundary;
}
if(this.Email != null) {
Data += "\r\nContent-Disposition: form-data; name=\"check_email\"\r\n\r\n";
Data += "on\r\n";
Data += "--" + Boundary + "\r\n";
Data += "Content-Disposition: form-data; name=\"email\"\r\n\r\n";
Data += this.Email + "\r\n";
Data += "--" + Boundary;
}
Data += "--\r\n";
byte[] DataBytes = (new System.Text.ASCIIEncoding()).GetBytes(Data);
System.Net.HttpWebRequest Request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create("http://127.0.0.1/");
Request.Method = "POST";
Request.UserAgent = this.Agent;
Request.Referer = "http://api.files.getwebb.org";
Request.ContentType = "multipart/form-data; boundary=" + Boundary;
Request.ContentLength = DataBytes.Length;
System.IO.Stream PostData = Request.GetRequestStream();
PostData.Write(DataBytes, 0, DataBytes.Length);
PostData.Close();
I've the same problem with the code from the MSDN : http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.method(VS.80).aspx
I've tried with Mono and with .NET, but nothing change.
Note : To intercept data, I've make a Python server who listen on the port 80, but with Fiddler, a HTTP debug proxy, I don't see data too.
Thanks
|
|
|
|
|
ok, at the risk of pointing out the bleeding obvious, it looks like the error is within your foreach(string Fichier in this.FilesList) loop ... you seem to know this, given you know what you have vs what you expect
so, what happens if you start debugging through that, checking the contents of FilesList etc ?
you should be able to isolate that code or single step it and see if the file is being opened and its contents being appended to 'Data' - yes ? (or have I missed something ?)
'g'
|
|
|
|
|
is there any way to change the font of Values in PG ? because it everytime appears in BOLD that looks very weird
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
there is any explicit property but through the reflection you may change it.
|
|
|
|
|
would you like to explain little more or any article ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
i want to save a DataTable in Properties.Settings. All just works fine untill i restart the app.
here is code on forms Load
if (Properties.Settings.Default.Limits_DT != null)
{
main_DT = Properties.Settings.Default.Limits_DT;
}
else
{
main_DT = new DataTable();
}
and another one is
private void LE_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.Limits_DT = main_DT;
Properties.Settings.Default.Save();
}
it works but only if application keep running. I dunno why Save() is not working. I use Settings often but this time i need a DT
any idea... ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Do you really need a datatable, or do you just need the data it contains ? What if you stored the data as XML ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
well, i want to save DT since its supports many things, constraints, typed column etc and very easy too use as well as xml do not do what exactly or nearly i want...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I want to record (video file) when i moved mouse on screen.
as same as program "lotus screen"
please give hint or tip to me.
Thank so much...
|
|
|
|
|
it may help
http://www.codeproject.com/KB/audio-video/capvidscrn.aspx[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I'm creating a lot a picture boxes. Each picture box has a constant height and width of 50. So I randomly place this picture boxes on the form. My problem is that some picture boxes overlaps or on top of other picture box. How do I solve this problem?
|
|
|
|
|
You need to look at the existing picture boxes and if they overlap with your new picture box then move your new picture box.
Detecting an overlap is fairly simple. Each control can give you its Bounds[^], which is a Rectangle[^] object. The Rectangle structure has an IntersectsWith[^] method which will return true if the rectangles intersect (overlap) with each other.
For example:
bool isOverlapping = firstPictureBox.Bounds.IntersectsWith(secondPictureBox.Bounds);
|
|
|
|
|
I've got a VisibleChanged handler in a UserControl class that performs some functionality that includes using "this ". When I run the code as an app, it works fine, but when I try to load the UserControl into the designer, the IDE crashes. Is there a way to hide code from the designer, like a convenient compiler directive or anything?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I don't know whether there is a directive or not but you can check whether the control is at design time or not. See here: Detecting Design-time in C#[^]
|
|
|
|