|
I am using DataGrid class. I cannot use DataGridView class in Mobile programming as the CF 2.0 doesn't support it.
Here is the code when the datagrid is clicked
private void dataGrid1_Click(object sender, EventArgs e)
{
DataRow flightDataRow = flightTable.DefaultView.ToTable().Rows[dataGrid1.CurrentRowIndex];
statusCombo.SelectedIndex = (int)statusHash[flightDataRow[6].ToString().Trim()];
gateCombo.SelectedIndex = (int)gateHash[flightDataRow[5].ToString().Trim()];
selectedDailyID = (int)flightDataRow[0];
selectedFlight = flightDataRow[3].ToString();
panel1.Visible = true;
panel1.Enabled = true;
dataGrid1.BringToFront();
}
After dataGrid1.BringToFront() is what I have to put the code where the datagrid should scroll to make sure that the selected row is visible. it is ok even if the selected row is the 1st row in the datagrid's view area.
Thanks,
Ashoo
|
|
|
|
|
I don't know if this will work (since DG is not really a list view), but you could try the following:
...
using System.Runtime.InteropServices;
using System.Windows.Forms;
...
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr handle, uint op, uint index, uint isPartialOK);
...
private const uint LVM_ENSUREVISIBLE = 0x1013;
...
private DataGrid dg = ...;
...
int selectedIndex = ...; // Get the index of the selected row
if (selectedIndex >= 0)
// the final parameter is 0 if the entire row needs to be shown, or 1 if partial showing is OK
SendMessage(dg.Handle, LVM_ENSUREVISIBLE, selectedIndex, 0);
...
Let us know if this works. (and yes, it is identical to the code in my last post except it uses DataGrid instead of DataGridView!)
Jeff
|
|
|
|
|
I tried it and it gives a MissingMethodException when I click on a row in the grid, for the SendMessage along with "Can't find PInvoke DLL 'user32.dll'.". I looked for user32.dll and that file is there, so i don't know how to fix it.
Thanks,
Ashoo
|
|
|
|
|
Try including the dll in your build output directory. Also change the DllImport to the following:
[DllImport("user32.dll", EntryPoint="SendMessageA", SetLastError=true)]
// Same line here
If that doesn't work, you could try to find the answer at one of the sites
here[^].
Let us know the results!
Jeff
|
|
|
|
|
Unfortunately I am unable to add the reference user32.dll, it says that a reference to user32.dll cannot be added. Also inspite of the above change I am still getting the same error as before. I even downloaded PInvoke.net and installed it.
Thanks,
Ashoo
|
|
|
|
|
You don't need to download anything, or reference anything. Just copy user32.dll into your executable directory.
Jeff
|
|
|
|
|
That was the first thing I tried and since that didn't work I downloaded the PInvoke.net.
Thanks,
Ashoo
|
|
|
|
|
Well, I'm stumped. Clearly this is related to the mobile device. I have never personally written anything for a mobile device, so I don't know what else to tell you. Hopefully someone else from the forum can help, or you can find some information through google on how to code against common windows dll's in a mobile environment. Sorry I can't do more for you, but be sure to post the answer if you find it so others can benefit (and so we can help the next guy with the same question).
Jeff
|
|
|
|
|
Thanks Jeff for all your help. I will surely post the answer when I find it. I think so too that it is related to mobile device. I think the user32.dll doesn't get deployed on the mobile when the rest of the code does and hence it not able to find the method.
Thanks,
Ashoo
|
|
|
|
|
i have a table EmployeeInfo in sql 2000 that have two attributes say EmpID & EmpName i am displaying the EmpName only in a datagridview but when i delete it it give error that cannot delete the key blah blah
so how to delete the whole row from sql2000
please note that i am only displaying the EmpName in the data grid
sas
|
|
|
|
|
There should be a property of the DataGrid called DataKeyField. Try setting this to the employee id and see if that works.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I am trying to develop an application using Windows Forms to have streaming IO such as would be used with Console.OpenStandardInput.
I want to be able to retrieve data from a Windows form in the same manner as using "Console.OpenStandardInput". Is there a way to do this!?
-- modified at 11:54 Monday 12th November, 2007
|
|
|
|
|
BGearig wrote: I want to be able to retrieve data from a Windows form in the same manner as using "Console.OpenStandardInput". Is there a way to do this!?
Your post doesn't make sense. The example for Consol.OpenStandardInput has the application reading the keyboard input from the console window. You state you want to retrieve data from the application not read it into the application.
I think you need to clarify your requirements if we have any chance of helping you. Also before doing that perhaps you might read this[^] as it might help your messaging attempts.
|
|
|
|
|
I will be giving a colleague training in C#, and would like to offer it in the form of a series of one day courses. I would like to cover beginners and intermediate level practical, real world, programming in, say, four courses, and I would like some input on my syllabus. So far I see language basics, and common tasks, e.g. basic data access, in course #1; collections and .NET classes, and Windows Forms essentials in course #2; component design and implementation, interfaces, inheritance, generics, reflection etc. in course #3; and course #4 as a guided practical project, of nature still to be determined.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Walk him through C# Step-by-Step by Microsoft press. You'll want to change some details on the way but it covers everything for the basics.
|
|
|
|
|
Have you tried just doing a ping on all the client instances, you know, just to see if they are running?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
yeah... i tried
actually i tested like braodcasting 1-100 numbers
@ client side i receives like Client A receives -> 1 3 4 5 10 11 12 (missing ...)
Client B receives -> 1 2 3 4 7 8 15 16 (missing ...)
Client C receives -> 4 5 6 10 11 12 15 (missing ...)
so thats what im wondering if sockets are useless though connection is "TCP"
Determination and faith are the only keys !
|
|
|
|
|
Hi everyone
My apologies if this has been asked before, I suspect it may have but does anyone know of any tutorials for C# ListBox drag and drop in which you are simply dragging FROM a ListBox to an external program such as simply Windows Explorer?
All the tutorials I seem to find are regarding making controls accept drag events.
Regards and thanks in advance.
|
|
|
|
|
You should be able to do the following:
...
using System.Windows.Forms;
...
private ListBox lb;
...
private void SomeEvent(object sender, EventArgs e) {
object data = ...; // set this to be the data you want to be dragged
// note that the data MUST be a type recognized by the system
// for it to be able to be dropped onto the desktop (like a file)
DragDropEffects result = lb.DoDragDrop(data, DragDropEffects.All);
// Do some stuff based on whether the result is move, copy, etc.
}
Hope this helps!
Jeff
|
|
|
|
|
Hi
The ListBox I am using contains a list of FileInfo objects.
Are these translatable to the desktop or external application?
Regards
|
|
|
|
|
Oh and If so how do you perform the actual act of copying?
|
|
|
|
|
|
Hi
The first link you posted I had found today and I've managed to get the code working! Meant to post up here a link but thank you for this.
The second is very useful and great thanks to you for this. My aim for the application is to drag from my application to an external application and such I can imagine the file descriptor being a problem. The tutorial on this section may be able to help with some of the problems that might arise!
Thanks again Jeff
|
|
|
|
|
Hi experts,
I wanted to create a multi threaded windows service, can anyone reply me with the code, i will appreciate it.
The scenario is, i have multiple databases, and i have to connect to each database and do some work after each interval using windows service.
I could not able to find a simple multi threaded windows service code sample anywhere
Help needed, thanks,
Vijay
Vijay
|
|
|
|
|
I would be surprised if anyone would be able to post code for this type of request. I have written a few multithreaded services and can give you some pointers.
1. I usually put all of the code used by the thread in its own DLL, that way you can basically insantiate an instance of you class for each thread and limit the race conditions which can occur between threads.
2. Create a single public method in your class which can be the starting point for your thread, populate class properties with initial values in the Service code then use the ThreadStart or ParameterizedThreadStart methods to start the thread. Once the Thread has started (you can use ManualResetEvents to monitor this) add the Thread instance to an array in the Service code so all of the running threads canbe managed from the service. Doing so will allow you to stop the threads in the event that the service must stop.
3. I've found that .NET remoting is especiall handy with M-threaded Windows Services for sending control / command requests to the threads.
Here is an example of starting a thread:
try
{
m_ThreadStarted.Reset();
Thread ADTThread = new Thread(new ParameterizedThreadStart(ProcessADTThread));
ADTThread.IsBackground = true;
m_MasterThreadList.Add(ADTThread);
ADTThread.Start(DR);
m_ThreadStarted.WaitOne(-1, false);
Lines.Append(DR["ClientName"].ToString() + " Started\r\n");
}
catch (Exception Err)
{
m_ServiceLog.WriteEntry("Start Service WaitEvent Exception: " + Err.Message, EventLogEntryType.Error);
}
|
|
|
|