|
There is no build-in way to do that. What I have done when I wanted to do something like that was create the CheckBox on the fly, and set the position to inside the row header you want it to be in. Then in the resize event on the control have it move the check box to the same position on the row header.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi,
I have a form that has a data grid on it with name and address columns.
When a user adds their name and address details to the table and clicks on the details button I want their data to automatically be added to the details form using text boxes.
I'm unsure of the code for data value details?
frm.customer =
Can someone please help me?
Thanks in advance
|
|
|
|
|
Set up a delegate to pass the data between forms
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 )
|
|
|
|
|
This, again has to do with graphics, because I 'lost' the other posts, but I still have the thoughts around. My plan was to make a VERY, basic simple game called 'Squares'. There are to squares. You move with the arrow keys (I completed this), and try to keep your square from touching the other. (I can do the collision). The only thing I need to now is how to move the square (player). I'm trying panel1.Invalidate(); right now...
Thanks again, for those who keep reading... AND in advance.
|
|
|
|
|
|
I'm not sure where you're stuck. You are changing the values for the square, but it's not redrawing ? If you have another square moving all the time, you should have a timer which, when it fires, changes the position of the other square(s) and calls Invalidate(). What's panel1 for ? You probably want no controls on your form at all, it will just comprise of the game. In this case, you call this.Invalidate(); this is superfluous, but it makes the scope clear.
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 )
|
|
|
|
|
Could you give an example? I tried this.Invalidate(); and nothing happened.
The most knowledge doesn't mean the most wise...
|
|
|
|
|
Invalidate will definately cause your form to repaint itself. Put a breakpoint on the invalidate call to see when it gets called, then when it's called, put one in your paint event and step through to see why your box is not being drawn as you expect.
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 )
|
|
|
|
|
What's a breakpoint do? Simple question probably, but I'm new...
The most knowledge doesn't mean the most wise...
|
|
|
|
|
I JUST GOT IT TO WORK!! THANKS A LOT!!!;P
The most knowledge doesn't mean the most wise...
|
|
|
|
|
NP - sorry I didn't come back sooner, very busy day for me today.
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 )
|
|
|
|
|
It's cool.
The most knowledge doesn't mean the most wise...
|
|
|
|
|
Hi to All,
This is my first aquaintance with the forum as I am new to this forum as well as C# also.
So the question may be foolish & yet it prevails.
Hope you understand me ..
Q: Is Application.Run() function always necessary to display your form? Can't we bypass it? I tried to do and my form instance was just flashing and exiting...
Thanks in anticipation..
Regards
-- modified at 3:25 Sunday 14th October, 2007
|
|
|
|
|
I'm almost 100% sure, that it is necessary.
Your application needs to be executed somewhere in the code.
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Hi,
to have a live Windows app, showing Windows and reacting to the user, you need
a "message pump", i.e. an event queue that collects GUI events, and a loop that reads
from that queue and executes the messages. The normal way to achieve this is by
calling Application.Run(); there may be other ways to achieve the same, but nothing
as simple as the one line that does everything that is required.
BTW: you don't need Application.Run() when you don't need the message pump, as in
a Console app.
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
|
|
|
|
|
Question - why do you think it's there, if it's not necessary ? Why do you want to bypass it ?
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 )
|
|
|
|
|
Thanks to all ...
Really..
So now I get that the message pump that is required is provided by Application.Run(). Otherwise the application would die without any messages..
Thanks once again folks.
|
|
|
|
|
dear all,
I need a way to query a dns for example "ns1.whatever.com" ;
in order to get domain entrys on this NS ...
i need to do something like this site http://domainsdb.net/[^] but in windows application ...
thanks in advance for your co-operation
Davids Maguire
|
|
|
|
|
Check this[^] out.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I'm going to break out my question into a smaller sub-question this time, instead of trying to fit two questions into one post.
I basically have a method Control.PerformOngoingOperation that can call other methods, with string IDs assigned to each calling. Its signature is, currently:
object PerformOngoingOperation(Delegate method, out string id, params object[] args)
However, as far as I can tell, the user then has to declare a delegate every time:
class C
{
delegate int annoying(int param1, bool param2, string param3);
void Method()
{
string id;
int retVal = (int)Control.PerformOngoingOperation(new annoying(Library.Object.Method), out id, 5, true, "test");
}
}
I suppose an alternative is requiring that the delegate be of type MethodInvoker (basically void return type, no parameters), as such:
string PerformOngoingOperation(MethodInvoker method)
and forcing the user to do this:
int retVal;
string id = Control.PerformOngoingOperation((MethodInvoker)(new delegate() { retVal = Library.Object.Method(5, true, "test"); }));
But that's awkward at best.
Ideally I would like to have something like this instead:
string id;
int retVal = Control.PerformOngoingOperation(Library.Object.Method, out id, 5, true, "test");
Is that possible? If so, what's the syntax?
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
Domenic wrote: string PerformOngoingOperation(MethodInvoker method)
Something like that, yeah.
One thing to keep in mind is, the C# 2 compiler can infer the delegate type. So if you define it with a MethodInvoker (or a SendOrPostCallback, or any other delegate), the compiler can infer the delegate from usage. For instance, you can call it like this:
Control.PerformOngoingOperation(Lib.Obj.Method);
Notice how you didn't need to declare new MethodInvoker(Lib.Obj.Method) , the C# compiler inferred that Lib.Obj.Method has a signature matching MethodInvoker, so you don't have to explicitly create a new delegate instance there. Does that help?
The reason this doesn't work with Control.PerformOngoingOperation(Delegate del, ...) is because the compiler doesn't know which delegate to use with it, so it forces you to create a new delegate around the function you pass in.
|
|
|
|
|
Right, but since very few of my "ongoing operations" are void and parameterless, this is pretty useless. I'd instead create anonymous delegates (as shown above), which in fact do have to be cast to MethodInvoker
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
You don't have to cast to MethodInvoker provided you specify an anonymous method that is parameterless and doesn't return anything. For example,
Control.PerformOngoingOperation(delegate()
{
Library.Object.Method(5, true, "test");
}
That will work just fine, no cast required.
It should be noted that in the .NET framework class libraries, it's a common practice to accept a method that returns void but takes 1 parameter of type object in order to pass in state.
For example, see ThreadPool.QueueUserWorkItem(SendOrPostCallback method, object state);
cc
Where SendOrPostCallback is a delegate that takes 1 object parameter.
Another thing you can do here is provide generic overloads for your Control.PerformOngoingOperation:
object PerformOngoingOperation(Function method, out string id)
</code><code>object PerformOngoingOperation<TArg>(Function<TArg> method, out string id, TArg arg)
</code><code>object PerformOngoingOperation<TArg1, TArg2>(Function<TArg1, TArg2> method, out string id, TArg1 firstArg, TArg2 secondArg)
</code><code>object PerformOngoingOperation<TArg1, TArg2>(Function<TArg1, TArg2, TArg3> method, out string id, </code><code>TArg1 firstArg, TArg2 secondArg</code><code>, TArg3 secondArg) And so on, as many as you like.
This way, your PerformOngoingOperation method can execute most any function without having to use the Delegate class; everything will be strongly typed and performance will be great as no late-bound method invocations will occur.
|
|
|
|
|
Hi ,
I am trying to read an MS Excel file in my C# class. But problem is its not showing me the column values. I have checked in actual excel file , those columns do contain values but due to some reason my code is not reading it.
here is what i m doing :
Code Blockstring filename = "xmp.xls;";
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source= " + filename + "Extended Properties=Excel 8.0;";
OleDbConnection ObjConn = new OleDbConnection(strConn);
ObjConn.Open();
object[] objArrRestrict;
objArrRestrict = new object[] {null, null, null, "TABLE"};
DataTable schemaTbl;
schemaTbl = ObjConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,objArrRestrict);
Hashtable ht = new Hashtable();
int index = 0;
foreach (DataRow row in schemaTbl.Rows)
{
ht.Add( index, row["TABLEX] );
index++;
}
string sheetName = (string)ht[0];
OleDbCommand ObjCmd = new OleDbCommand( "SELECT * FROM [" + sheetName + "]", ObjConn);
OleDbDataAdapter objDA = new OleDbDataAdapter();
objDA.SelectCommand = ObjCmd;
objDA.Fill(recordsDT);
ObjConn.Close();
DataRow rowx= recordsDT.Rows[14];
// and now if i try to read value of 6th column
rowx[5].ToString(); // gives empty string
rowx["6th Col"].ToString(); // it returns me empty string and actually this column do contain value
and similary i can't get values of col 7,8 but I do get the values of Col 1-5 and after Col 9.
But if I try to same column values of row 1,2 it works fine. It starts to get funny after row no 7. ( each row contains 80 coumns)
Thanks
ZINK
|
|
|
|
|
Hi would appreciate if you helped me with this strange problem.
i´m trying to write text from my listview into a excel file but the problem is that i want to change cells, now its writing in the same cell.
for example:
a1 a2 a3 a4
subitem[0] subitem[1] subitem[2] subitem[3]
subitem[0] subitem[1] subitem[2] subitem[3]
tryade this:
using (StreamWriter sw = new StreamWriter((path3 + namn), true))
{
for (int listIndex = 0; listIndex < this.listView2.Items.Count; listIndex++)
{
sw.WriteLine(this.listView2.Items[listIndex].Text + this.listView2.Items[listIndex].SubItems[1].Text + this.listView2.Items[listIndex].SubItems[2].Text + this.listView2.Items[listIndex].SubItems[3].Text);
}
Process.Start(namn);
enyone with a good knowledge with this problem???
TNX!!;)
|
|
|
|
|