|
As you've been told, the sort method isn't really suitable on large data sets. It's important to understand that this is really the wrong place to apply sorting on large data sets - assuming it's coming from a database then the best way to do this is to retrieve the data already sorted and then fill the list.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
How do I format Column when a Gridview loads?
Details:
I have a grid named : SubcategoryGrid
the grid is binded to a data binding source.
there is a column in that grid(double type), I need to apply a simple conversion formula after the data binding completes
what gridview argument do I use? or how would I go on about this?
|
|
|
|
|
Hi,
have a look at the CellFormatting event. You could watch the value (e.Value) to be displayed and:
1. modify it,
2. or apply a special formatting (dgv.Columns[COL].DefaultCellStyle.Format="#,###";),
3. or set a special backcolor (e.CellStyle.BackColor=Color.Yellow; however this does not work for empty cells!).
I have used some of the above in my CP Vanity[^] article.
|
|
|
|
|
Thanks,
this is what I have:
Class:
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
}
What args do I use in designer??
I tried this event to trigger cellformating:
this.SubcategoryGrid.DataBindings += ........
|
|
|
|
|
AFAIK there are two distinct mechanisms, one to provide the data (databinding), one to display the data (formatting).
The binding is whatever you want it to be.
The formatting will fire the CellFormatting event if you wire it up, which you can do by double-clicking the event in the events list, or by adding a dataGridView1.CellFormatting+=dataGridView1_CellFormatting; statement in the form's constructor. As you already have the outline, you probably have done the former already.
Now start manipulating the current cell inside your event handler, any way you want (You did not specify what kind of "simple conversion formula" you want).
|
|
|
|
|
Cellformating worked.
Thank you!
|
|
|
|
|
Why does it have to happen after the binding?
Is there some reason you can't use DataFormatString[^]?
|
|
|
|
|
That is for a WebUI thingy, isn't it? I believe the OP wants a WinForm with a DataGridView.
|
|
|
|
|
|
T M Gray wrote: Ahh he used the wrong control name
Happens all the time, we all get used to it.
|
|
|
|
|
I'm working on loging into an SMF based message board using a WebClient with a cookie collection. So far I've been able to use existing cookies to connect and download pages as needed, however I have to hard code the cookies to do it. Obviously not a good option.
The problem I'm running in to is that in order to have the server generate credentials I have to give it a log in name and a hashed password. The forum login generates them using sha1 hashing with this code:
<br />
doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);<br />
I've been trying to use
<br />
private void btnLogin_Click(object sender, EventArgs e)<br />
{<br />
String sName = "test";<br />
String sPassword = "login";<br />
String sSessionID = "3d847dffa233343cc5065a82b73d566e";<br />
<br />
SHA1 sha = new SHA1CryptoServiceProvider();<br />
byte[] sResult = sha.ComputeHash(StrToByteArray(sName + sPassword));<br />
sResult = sha.ComputeHash(StrToByteArray(ByteArrayToStr(sResult) + sSessionID));<br />
}<br />
<br />
public static byte[] StrToByteArray(string str)<br />
{<br />
return Encoding.UTF8.GetBytes(str);
}<br />
<br />
public static string ByteArrayToStr(byte[] bytes)<br />
{<br />
return BitConverter.ToString(bytes).Replace("-", "").ToLower();<br />
}<br />
<br />
To generate the same hash as the php version...however it's obviously failing. Somewhere in there I'm missing some encoding or particular formatting that I don't know about. Can anyone point me in the right direction here?
EDIT:
<br />
String sName = "test";<br />
String sPassword = "login";<br />
String sSessionID = "8000e537c2a7a31547ffa779fab7a1e2";<br />
String sTemp;<br />
<br />
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();<br />
sTemp = BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(sName + sPassword))).Replace("-", "").ToLower();<br />
textBox2.Text = BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(sTemp + sSessionID))).Replace("-", "").ToLower();<br />
After beating my head against a wall long enough I was able to come up with this, and it does spit out the exact same hash as the existing php code. This should allow anyone to generate a hash for logging into most SMF powered message boards (They seem to have a niche market in games and mods on a global scale.)
I was a bit surprised to notice codeproject itself doesn't actually hash passwords, it sends them in clear text.
modified on Thursday, July 15, 2010 7:12 AM
|
|
|
|
|
Maybe it should be
byte[] sResult = sha.ComputeHash(StrToByteArray(sName + sPassword));
byte[] sSessionResult =sha.ComputeHash(StrToByteArray(sSessionID));
byte[] returnResult = bew byte[sResult.length + sSessionResult.length];
Array.Copy(sResult, returnResult , 0, sResult.length);
Array.Copy(sSessionResult, returnResult , sResult.length, sSessionResult.length);
sResult = returnResult ;
Fix the compile errors because I just typed this in but I don't think your .NET code matches the PHP code.
|
|
|
|
|
I know the basics of documenting my code for intellisense but I have had alot of trouble finding a good tutorial that shows where the info will be displayed etc.
If anyone knows of a link that would be great.
I could probably find this myself if I knew what MS actually called documenting in this way.
I see things in the framework displaying in intellisense the way that I want but I have had trouble figuring out how they did it.
Thanks again for everyone's help.
Humble Programmer
|
|
|
|
|
Delimiters for Documentation
|
|
|
|
|
Um. Did you mean that as a link, Luc?
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Nope. I decided to leave some room for personal initiative, as I wasn't too impressed by the question.
|
|
|
|
|
I'm impressed - it worked!
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
|
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Luc Pattyn wrote: personal initiative
Well congrats. Looks like you actually found one with some initiative.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Just what I needed Luc thanks again.
Humble Programmer
|
|
|
|
|
|
Hi...
I want to develop a C File using C#3.0 which will create the header file with structures, enums, macros..and all other features of the C..
I want to develop a tool in which i have a GUI and i have to select the options from GUI and accordingly i have to create a C file for the same
So is it possible in C#3.0?
|
|
|
|
|
Sounds like an IDE. A C-sourcefile is usually in ASCII, meaning that it's plain text. You can compile this source off course, even using an external compiler.
Should I imagine a code-generator, or more of a forms-generator?
I are Troll
|
|
|
|
|
thanks for ur reply..
Basically I am doing a project in which i will be designing a GUI and from there by taking the input I want to generate the C code in a file with ".C" extension. I will be using a different compiler to compile that C File.
So is it possible?
|
|
|
|