|
|
Google doesn't work where you live ?
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 )
|
|
|
|
|
what is Internet Directory Services ?
Lalit
|
|
|
|
|
|
Could you please use a more meaningful post title. This forum is C#, so we already know the language you are dealing with. Note however, that your question would have been more suitable in the General Questions forum because it isn't language specific.
|
|
|
|
|
Try googling it and use a more meaningful subject line.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
any body pls tell me how to add checkbox in DataGridView column header?
quick response highly appriciated.
Ramana
|
|
|
|
|
Their is No way to add check box on a header.
But What I suppose you want to give a Check box on header that and on selection of that all the checkboxes of remaining rows are automatically selected right...?
If it is true then do this...
1. Place a check box control on a form.
2. Remove its text and set its position to the column header.
3. On Checked Change event of it write this
<br />
for (int cnt = 0; cnt <= DataGridView1.Rows.Count - 1; cnt++)<br />
{<br />
DataGridView.Rows[cnt].Cells["ColSelect"].Value = true;<br />
}<br />
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Hi All,
TO use pointers ,I have tried to make the code Unsafe.but there is still error..The code is given below..
public unsafe class node
{
//attributes.......
private string TableName;
private node *Next;
private ArrayList *ColName;
public node()
{
Next = null;
TableName = null;
ColName = null;
}
}
Error "Cannot take the address of, get the size of, or declare a pointer to a managed type"
Regards,
chanzeb chaudhary.
|
|
|
|
|
correct, you can't.
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 )
|
|
|
|
|
in C# pointers are applicable to value types only. Example: pixel bytes inside a Bitmap,
but not the whole Bitmap.
|
|
|
|
|
I would like to make a "dumb" conversion factory, to convert one type to another (call them types A and B). To perform this action, I require that I can construct the return type with a default constructor. I will then take all the public read/write properties of both A and B, compare them, then copy the matching ones over. However, I want this to be a generic operation, that can convert between any two classes. Therefore, I am attempting to do the following:
public class AbstractBase<T, U> where T : AbstractBase<T, U> {
public static implicit operator T(U other) {
T rval = new T();
foreach (PropertyInfo Upi in typeof(U).GetProperties()) {
PropertyInfo Tpi = typeof(T).GetProperty(Upi.Name, Upi.PropertyType);
if (Tpi != null && Tpi.CanWrite && Upi.CanRead
&& Upi.GetIndexParameters().Length == 0)
Tpi.SetValue(rval, Upi.GetValue(other, null), null);
}
return rval;
}
public static implicit operator U(T other) {
U rval = new U();
foreach (PropertyInfo Tpi in typeof(T).GetProperties()) {
PropertyInfo Upi = typeof(U).GetProperty(Tpi.Name, Tpi.PropertyType);
if (Upi != null && Upi.CanWrite && Tpi.CanRead
&& Tpi.GetIndexParameters().Length == 0)
Upi.SetValue(rval, Tpi.GetValue(other, null), null);
}
return rval;
}
} And then declare a user to this class as follows:
public class myClass : AbstractBase<myClass, otherClass> { ... } I know that one of the types passed in, say T, implements AbstractBase<T, U>, so I thought that I could do the above, since my conversion is from one type that inherits from this class to some other unknown type. However, I get the error that I can only convert between types related to the class. Does anyone know a way around this so I can use the above code without retyping it in every single class (like myClass in the above example) where I need this functionality? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I suspect that you need to put a new() constraint in
public class AbstractBase<T, U> where T : AbstractBase<T, U> new()
where U : class, new()
|
|
|
|
|
My current solution is to include these methods in a static utility class as template methods, then call them from within the class that will use them to convert to/from it's type. That way, I only need one definition as follows:
public static class Helper {
public static T Convert<T, U>(U other) where T : new() {
}
}
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I had to write a validation function for some data being read from an app.config. The point of the validation was to ensure that the value was a power of 2 and within a certain range (4k - 4mb). This is how I did it:
private bool IsPowerOfTwo(int numeric, int min, int max)
{
bool valid = false;
if (numeric >= min && numeric <= max && numeric % 2 == 0)
{
int pow2 = min;
while (pow2 <= max && !valid)
{
valid = ((pow2 *= 2) == numeric);
}
}
return valid;
}
Assume that the min and max values are valid powers of 2. I passed in the values 4096 for min, and 4194304 for max).
How would you do it?
"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'd make sure there was only one '1' in the binary representation of the number.
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 )
|
|
|
|
|
Hi John, the following test applies to signed integers and returns true if and only if the
value is either zero, a positive power of 2, or the minimum value (which equals the negative
of a power of 2); it basically checks that there are either zero or one bits set:
(x & -x)==x
It relies on the fact that -x, when looking from right to left, preserves all the low-end zeroes
of x, as well as one low-end one, and flips all the other bits.
|
|
|
|
|
Pretty nifty, I must say
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Found this nifty little function as part of the excellent AForge library [^]
public static bool IsPowerOf2(int x)
{
return (x & (x - 1)) == 0;
}
|
|
|
|
|
yep, that's mathematically equivalent to mine. It too calls zero a power of two.
PS: how is the memory?
|
|
|
|
|
Luc Pattyn wrote: PS: how is the memory?
Haven't solved it yet. We are profiling it over several days to get a better picture. Will let you know what happens.
|
|
|
|
|
An alternative approach could be:
private static bool IsPowerOf2(double number)
{
double value = Math.Log(number, 2);
return value == Convert.ToDouble(Convert.ToInt32(value));
}
|
|
|
|
|
Hi,
i have added one checkbox to my datagridview..
i want to select the checkbox....
after selecting the check box i need to get the whole row details of that perticular checked row..
DataGridViewCheckBoxColumn ckb = new DataGridViewCheckBoxColumn();
ckb.Name = "Checkbox";
ckb.HeaderText = "Select";
dataGridView1.Columns.Insert(0, ckb);
how do i select and deselect the checkbox check options...
please reply me ASAP
|
|
|
|
|
<br />
for (int cnt = 0; cnt <= DataGridView1.Rows.Count - 1; cnt++)<br />
{<br />
DataGridView.Rows[cnt].Cells["ColSelect"].Value = true;<br />
}<br />
1. Where ColSelect is your column name.
2. If you want to de-select just write false instead of true.
3. And if you want to know which row is checked and which is not then
<br />
for (int index = DataGridView1.Rows.Count - 1; index >= 0; index--)<br />
{<br />
if (Convert.ToBoolean(DataGridView1.Rows[index].Cells[0].Value))<br />
{<br />
"Selected"<br />
}<br />
else<br />
{<br />
"Not Selected"<br />
}<br />
}
<br />
:-D <br />
<br />
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Hi,
I am writing my first control and would like to create an event so the form the control is sitting on can pick up user activity in the control.
How can I do this?
Thanks in advance.
Stephen
|
|
|
|