|
Fred2834 wrote: I want to know what I have to write in the OnStart method to actually make sure the service does not go into "running" mode if something fails (ex: loading the config). I would assume throwing an exception would suffice.
/ravi
|
|
|
|
|
There's various ways of doing it, with equally various opinions on what's appropriate.
The quick'n'dirty method is to set the this.ExitCode to a non-zero value specifying what the Win32 error was and then call the this.Stop() method.
|
|
|
|
|
.. geez, should have thought about that!
Thanks !
|
|
|
|
|
I have a C# application with a ListView and GridView control.
I would like to simulate the mouse click in both control simultaneously.
I would like to work this functionality even if the wind is not foreground.
So I used PostMessage to do the selection.
private void PerformSelection( List<int> rows, SelectionType selctionType )
{
IntPtr wParam = MK_CONTROL;
switch ( selctionType )
{
case SelectionType.Ctrl:
wParam = MK_CONTROL;
dataGridView1.VirtualKey = Keys.Control;
break;
case SelectionType.Shift:
wParam = MK_SHIFT;
dataGridView1.VirtualKey = Keys.Shift;
break;
case SelectionType.CtrlShift:
wParam = MK_CONTROLSHIFT;
break;
}
dataGridView1.Focus();
foreach (int rowIndex in rows)
{
SetScrollPositionListView( rowIndex );
NativeMethods.PostMessage( listView1.Handle, WM_LBUTTONDOWN, wParam,
(IntPtr) ( ( listView1.Items[rowIndex].Position.Y << 16 ) | listView1.Items[rowIndex].Position.X ) );
NativeMethods.PostMessage( listView1.Handle, WM_LBUTTONUP, wParam,
(IntPtr) ( ( listView1.Items[rowIndex].Position.Y << 16 ) | listView1.Items[rowIndex].Position.X ) );
SetScrollPosition(rowIndex);
dataGridView1.Focus();
Rectangle dgvRect = dataGridView1.GetRowDisplayRectangle(rowIndex, true);
NativeMethods.PostMessage(dataGridView1.Handle, WM_LBUTTONDOWN, wParam, (IntPtr)((dgvRect.Top + 1 << 16) | dgvRect.Left + 1));
NativeMethods.PostMessage(dataGridView1.Handle, WM_LBUTTONUP, wParam, (IntPtr)((dgvRect.Top + 1 << 16) | dgvRect.Left + 1));
}
}
private void SetScrollPositionListView( int rowIndex )
{
listView1.EnsureVisible( rowIndex );
}
private Point GetRowLocationListView( int rowIndex )
{
SetScrollPositionListView( rowIndex );
Point listViewlocation = listView1.PointToScreen( Point.Empty );
Rectangle listViewRect = listView1.GetItemRect( rowIndex );
int left = listViewlocation.X + listViewRect.X + ( listViewRect.Width / 2 );
int right = listViewlocation.Y + listViewRect.Y + ( listViewRect.Height / 2 );
return new Point( left, right );
}
For ListView the Ctrl + selection working fine. But for datagridview the only single Selection is working, the Ctrl Keydown is not working for datagridview.
When I give 1 2 3 as items to be selcected, the corresponding items selected in lisview, but for datagrid view only the last given item (3) is selected.
Could you please let me know why the above code is not working fro datagrid view.
Note: DataGridView.MulitiSelect property is True
aks
modified 30-Dec-13 3:01am.
|
|
|
|
|
From MSDN: "If the function succeeds, the return value is nonzero."
What's your return value? And which of the two currently has input-focus? (Receiving keyboard events)?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, the PostMessage is returning true as always.
The focus is in datagidview.
I have updated my query with an explanatory code snippet. Could you please have a look at that also.
aks
|
|
|
|
|
Don't take it the wrong way, but can you verify the setting of the DataGridViews MultiSelect[^] property? Verify that it's set to true?
Also, if you have a pointer to the datagridview-object, then why not simply set the collected items using code?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, I reassured the DataGridView's MultiSelect property is true. From GIO i am able to multi select the rows by using Ctrl and Shift.
Thank you Eddy for the suggestion But my intention id an automation interface which works for both ListView and DataGridView. I surely need to simulate the actual user selection by PostMessage.
aks
|
|
|
|
|
aks. wrote: I reassured the DataGridView's MultiSelect property is true. Can you (debug).print the amount of rows selected? Kinda hoping that the selection is there, but not correctly shown (think "HideSelection" properties and the likes).
aks. wrote: I surely need to simulate the actual user selection by PostMessage. Not really; one does not need to test whether the DataGridView still handles mouse-messages correctly - that part of the code did not change. And it does not "have" to be using windows-messages, you could use the PerformClick method from a button to simulate a mouseclick.
Is there anyone looking at the grid and view when the test-suite makes it selection? Or does the test run without supervision?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have one button inside modalpopup, when i click on that button than data bind on repeater, there is linkbutton on inside repeater.when i click on linkbutton than respective itemcommand not getting called.
Thanks
<asp:UpdatePanel ID="upd" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate><ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderDetails" runat="server" TargetControlID="aShowpoup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground" PopupControlID="pnlpopup">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnSearch" CssClass="button" runat="server" Text="Search" OnClick="FflSearch_click"/>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Width="1000px " Style="display: none;">
<asp:Repeater ID="rptrAllResults" runat="server" OnItemCommand="rptrAllResults_ItemCommand"
OnItemCreated="rptrAllResults_ItemCreated">
</asp:Repeater>
</asp:panel>
</ContentTemplate>
</updatepanel>
protected void rptrAllResults_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}
protected void FflSearch_click(Object sender, EventArgs e)
{
ModalPopupExtenderDetails.Show();
}
|
|
|
|
|
Kundan Saw wrote: itemcommand not getting called. How did you check? Put a breakpoint in the method?
I'm not good with ASP, but you might want to compare your code with the sample on MSDN[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you Eddy for your reply..
I have already check with break point. but only itemcommand is not getting fired with repeater(Note: Repeater is inside of ajax modalpopup.)
when i use without ajax modalpopup than it looks good.
|
|
|
|
|
Hi
I used the axShockwaveFlash controls to show "swf" under vs2012(c# winform). The swf file is created by flash builder4, and it contains the modle which is created by away3D.But the screen displays white,however I used axShockwaveFlash controls to show "swf" which is without away3d ,and swf runs normally .
Besides the swf canbe played in the flash player.I excluded the problem of sandbox security.If someone can help me to show swf I'll appreciate about it!
|
|
|
|
|
Flash is not a native component of the .NET framework; you'll probably get better support at one of the flash-forums. Adobe has their own[^], click on 'discussions' to get a list.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I will having a try!
Thanks.
|
|
|
|
|
You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I created a generic type called: Table<T>, and I create an instance of him using T as 'OrderItem' element.
Now I need to set him into other instance that should suppot multiple types, so I decided to use object:
private Table<object> currentTable;
Now I'm trying to set the OrderItem table, to the Object table:
currentTable = mainWindow.OrderItemTable;
And I'm getting this error:
"Cannot implicitly convert type 'BusinessLogic.Table<Entities.OrderItem>' to 'BusinessLogic.Table<object>'".
OrderItem isnt implement IConvertible, so I can't use ConvertType, also casting isn't working.
Any suggestions?
Thanks.
|
|
|
|
|
You can't convert a collection of anything to a collection of something else:
List<string> ls = new List<string();
List<object> lo = (List<object>) ls;
Unless the collection defines a cast operator that supports it.
So you will need to explicitly define a conversion as part of your generic class:
public static implicit operator Table<object>(Table<T> t)
{
Table<object> to = new Table<object>();
...
return to;
}
How you actually do the conversion is up to you!
You will probably need to explicitly declare a conversion back again as well...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
Thanks, that works greate for me.
|
|
|
|
|
You're welcome!
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
Hello
I have created Printer from c# and it called Myprinter How I can when user print any document show my program(redirect it to a external program) .
thanks very much
|
|
|
|
|
|
Hello
I have to use VS 2012 and C++
Or I can use VS 2010 C#
Thanks..
|
|
|
|
|
Since a driver is (effectively) part of the Windows OS you will need to write it in C/C++.
Veni, vidi, abiit domum
|
|
|
|
|
I write my project in C#.
I have to rebuild my project in C++ or there other way to create driver printer
|
|
|
|