|
hi all.. i am new programmer almost,and i wana thank u all here guys for this great site and quick support,
the problem: i want make a program that press the keyboard
keys by its self after a period of time,
how can i do that using c#? and thanks for all.
|
|
|
|
|
your problem(question) is open to multiple understandings . However, I will assume that you are trying to intercept keyboard event(s) for your application.
If you are trying to intercept the keyboard event for a specific control/form,
you can use the OnKeyDown event
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
Thread.Sleep(1000);
}
Otherwise, you might want to take a look at Windows Hooks.
Refer http://www.codeproject.com/csharp/GlobalSystemHook.asp
|
|
|
|
|
Read documentation for SendKeys and Timer Classes.
|
|
|
|
|
Use the SendKeys class to send keystrokes or keystroke combinations to the active application.
www.troschuetz.de
|
|
|
|
|
Hi, I am making a C# application that uses DirectX.
I did not have the DX SDK so i downloaded the "DirectX 9.0 SDK Update - (Summer 2004)"
However, intellisense (in Visual Studio Whitbey) still doesnt show the Microsoft.DirectX API.
What am I doing incorrectly?
thx
|
|
|
|
|
Have you added a reference to the project?
|
|
|
|
|
I tried building a Direct3D application with visual studio .net 2005. It works on my machine, be sure you have installed Managed DirectX and added a reference to the following assemblies:
- Microsoft.DirectX
- Microsoft.DirectX.Direct3D
- Microsoft.DirectX.Direct3DX
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
Thanks for the help, i didnt know i had to add the references manualy.
|
|
|
|
|
Is it possible to select full row in DataGrid instead of cells?
|
|
|
|
|
|
Question is incorrect, I don't want to select full row, I want to disable selecting of single cell,so user must always select full row. Is this possible?
Thanks for any help
|
|
|
|
|
Paste the below code in MouseUp. Will solve your purpose.
private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = DataGrid1.HitTest(pt);
if ( e.Button ==MouseButtons.Left)
{
if(hti.Type == DataGrid.HitTestType.Cell)
{
DataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
DataGrid1.Select(hti.Row);
}
}
}
Do revert back whether it could solve your purpose or not.
Regards,
Jay.
|
|
|
|
|
Thanks alot this works, but now when I click on cell
program first selects whole text in cell,
and then selects full row.
I tryed putting all code in MouseDown, and
"DataGrid.Select(hti.Row)" in MouseUp,
this almost solved the issue but selection is stil visible.
Can I avoid this?
Regards,
J.a.c.k
|
|
|
|
|
Hi Jack,
I am sorry I could not get your response completely. Will you please ellaborate what do you mean by stating "this almost solved the issue but selection is stil visible.
Can I avoid this? "
Last time when I gave you the code. I had not checked whether it is working properly or not. Today I made a demo application to test the code. It works for me.
I am not sure but please check whether you have changed / modified some of the dataGrid properties like SelectionBackColor , SelectionForeColor etc..
Regards,
Jay.
|
|
|
|
|
Hi Jay,
My English is not very well but I'll try to explain:
Code works fine and it solved problem, but when I click somewhere in grid program selects text in that cell like before I entered your code and then it selects complete row (all selection colors are set). So selection doesn't look nice, I was wondering can this be avoided?
Thanks for your time.
Regards,
J.a.c.k
|
|
|
|
|
Hi Jack,
I got your problem.
This can be solved by p/invoking LockWindowUpdate .
In MouseDown you lock the window update and in MouseUp you need to unlock it.
Please revert back whether you could do as mentioned above.
Otherwise I will send you the code showing How to do it?
Regards,
Jay.
|
|
|
|
|
Thanks Jay it works, just one more question:
How can I select first row of DataGrid in form_load event, if I could simulate click on first row then my mouse_up and mouse_down events would apply on that row. Is there an easy way of doing this?
Regards,
J.a.c.k
|
|
|
|
|
Simply call myDataGrid.Select(0) , as below:
if(myDataGrid.VisibleRowCount > 0)
{
myDataGrid.Select(0);
}
|
|
|
|
|
I can save a date but not a time like 11:01 any ideas, the grid is bound to a wizard generated dataset
Thanks for any help
jnc
|
|
|
|
|
How do you mean you can't save time? Explain!
![Confused | :confused:](https://www.codeproject.com/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
Many thanks for your reply
I have a test app with a bound grid a number of columns two are Time
I have a seperate routine which defines the columns of the grid
for the relevant column
DataGridTableStyle ItemList= new DataGridTableStyle();
ItemList.MappingName="TblEventitems";
DataGridTextBoxColumn Col3=new DataGridTextBoxColumn ();
Col3.Headertext="Start";
Col3.MappingName="EIStart";
Col3.Format="HH:mm";
Col3.NullText="00:00";
Col3.Width=50;
Col3.Alignment=HorizontalAlignment.Center;
ItemList.GridColumnStyles.Add(Col3);
DataGrid1.TableStyles.Add(ItemList);
other columns save OK even for the same record but the time remains 00:00 I have tried removing the NullText format
The Date saves OK (which I don't need) but the time is 00:00 If I change the time directly in the table it displays Ok in the grid but then I get a Concurrency Violation if I try to update
|
|
|
|
|
hi,
You can show time on your datagrid. For more details view this site
datagrid in codeproject
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi...
I have made a RichTextBox and wants to save the text...!
but it keep throws an error..!
My code is like this...
RichTextBox TextTest = new RichTextBox();
TextTest.Multiline = true;
TextTest.Text = "Test on savint" + "\n";
TextTest.Text += "here is something" + "\n";
TextTest.Text += "And some more" + "\n";
Stream TextSave;
SaveFileDialog spil = new SaveFileDialog();
spil.Filter = "TXT fil|*.txt|Alle filer|*.*";
spil.Title = "Gem fil som tekstfil";
spil.InitialDirectory = Directory.GetCurrentDirectory();
if(spil.ShowDialog() == DialogResult.OK)
{
if((TextSave= spil.OpenFile()) != null)
{
TextTest.SaveFile(TextSave, RichTextBoxStreamType.PlainText);
TextSave.Close();
}
}
But it trows an errer -> System.NullReferenceException: Object no set to an instance of an object!
Can anyone help me what to do?
QzRz
|
|
|
|
|
QzRz wrote:
But it trows an errer -> System.NullReferenceException: Object no set to an instance of an object!
At what line>?
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi.. sorry i didnt write...
The error is thrown here -> TextTest.SaveFile(TextSave, RichTextBoxStreamType.PlainText);
QzRz
|
|
|
|