|
dornala wrote: It is good practice to give entire connection object.
I don't understand what you mean. What is a simple connection? The only way to connect to a database with ADO.NET is with a connection object.
|
|
|
|
|
Hi
I wonder if anyone can help with this one, I've tried casting round on the net but couldn't find a solution.
I'm working on an MDI winforms app which contacts a web service to retrieve data. I use the MdiChild form Icon, linked to a Timer, to mimic am animated gif whilst the app is away fetching data - giving the app users a sense that something is happening:
<br />
private void TimerIconWorking_Tick(object sender, System.EventArgs e)<br />
{<br />
if (this.Icon.Equals(this._IconWorking)) <br />
this.Icon = this._IconWorking90;<br />
else if (this.Icon.Equals(this._IconWorking90)) <br />
this.Icon = this._IconWorking180;<br />
else if (this.Icon.Equals(this._IconWorking180)) <br />
this.Icon = this._IconWorking270;<br />
else if (this.Icon.Equals(this._IconWorking270)) <br />
this.Icon = this._IconWorking;<br />
else
TimerIconWorking.Enabled = false;<br />
}<br />
This works prefectly well while the MdiChild WindowState is Normal, however, once I maximize the form the MdiChild Icon does not get redrawn via the timer event. [Note this is the MdiChild (form level) Icon, not the MdiParent (application level) Icon.] The event fires fine, the code above gets executed as expected, but the Icon is not refreshed - except when I click off the app while the timer event is executing; then the redraw happens... (I think this is a clue but I'm not sure how to interpret it!)
I've tried to force the app to refresh by adding something like this to the event above but to no avail:
<br />
if ((this.WindowState == FormWindowState.Maximized)&&(this.MdiParent != null))<br />
{<br />
}<br />
1) Is there any obvious way to force a refresh the MdiChild form Icon whilst the form is maximized?
2) If the MdiParent.Menu area (where the MdiChild.Icon resides when the MdiChild is maximized) is rendered by Windows, rather than by the MdiParent, is there any way to force Windows to render this area of the MdiParent?
Cheers
HN3
|
|
|
|
|
Hi,
Try to use this line of code to refresh instead the Refresh() method.
Application.DoEvents();
|
|
|
|
|
Hi there,
Thanks for taking the time to reply, unfortunately this doesn't have any effect.
Cheers,
HN3
|
|
|
|
|
i want to reterive from dataset to fill my report
but i don't know how to do that
can i body tell me how
ma_refay
|
|
|
|
|
|
hi
First place report control on form and Add crystalreport to project by click ing AddNewItem add select CrystolReport template item,
gothrough one by one to add Database And its Coumns,
here is the code in ADO.net
MySqlConnection conn;
MySqlCommand cmd;
MySqlDataAdapter adap;
conn = new MySqlConnection("Server=localhost; Database=saf; User ID=root; Password=root; charset=utf8;"); conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = "SELECT customer_code, customer_name, customer_address FROM Customers";
adap = new MySqlDataAdapter();
adap.SelectCommand = cmd;
DataSet ds=new DataSet();
adap.Fill(custDB, "Customers");
CrystalReport1 myReport = new CrystalReport1();
crystalReportViewer1.ReportSource = myReport;
Winning is not our dream, It's a habit...
Have a nice evening
|
|
|
|
|
Hello
can someone tell me the method to retrieve the text of a cell that is selected at runtime in a DataGrid.
plz keep in mind that im working with .Net 2003 and do not have the DataGridView option.
Saira
|
|
|
|
|
if(dataGrid1.CurrentCell != null)
value = dataGrid1[dataGrid1.CurrentCell].ToString();
life is study!!!
|
|
|
|
|
SeishinLovesC#
u're the best
regards
Saira
|
|
|
|
|
With coding, or using remote connection type software such as Remote Desktop?
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi,
I write this code in the "CurrentCellChanged" event
private void dataGirdView1_CurrentCellChanged(object sender, EventArgs e)
{
txtName.Text = dataGirdView1[1, dataGirdView1.CurrentRow.Index].Value.ToString();
}
But this exception occur that when DataGirdView fiiling;
System.NullReferenceException: Object reference not set to an instance of an object
|
|
|
|
|
private void dataGirdView1_CurrentCellChanged(object sender, EventArgs e)
{
if(dataGirdView1.CurrentRow!=null)
txtName.Text = dataGirdView1[1,dataGirdView1.CurrentRow.Index].Value.ToString();
}
life is study!!!
|
|
|
|
|
I try dataGirdView1.CurrentRow.Index but its not work. It's big mistake.
Your code is working, thanks a lot...
|
|
|
|
|
my SendMessage project code:
private void button1_Click(object sender, EventArgs e)
{
IntPtr tohandle = FindWindow(null, "Sub Form");
Point pt = new Point(99, 100);
int iSize = Marshal.SizeOf(typeof(Point));
IntPtr lp = Marshal.AllocHGlobal(iSize);
Marshal.StructureToPtr(pt, lp,true );
if ((int)tohandle != 0)
{
SendMessage(tohandle, 789, IntPtr.Zero , lp);
}
}
my recieve msg project code :
protected override void DefWndProc(ref Message m)
{
if (m.Msg == 789)
{
Point pt = (Point)Marshal.PtrToStructure(m.LParam, typeof(Point));
string message = string.Format("{0},{1},{2},{3}",m.Msg ,m.WParam,pt.X ,pt.Y );
this.listBox1.Items.Add(message);
}
base.DefWndProc(ref m);
}
my issue:
m.Msg and m.WParam is ok ,but pt is error data, Why?
|
|
|
|
|
You did not explain much about what it is you want to achieve.
So I am guessing you want to send a user-defined message to a window
that does not belong to the same process ?
if so, it is a rather simple PInvoke exercise as long as no pointers need
to be passed.
When the message is to another process AND it needs a pointer to some data,
then it becomes trickym since that pointer now must make sense in the
destination process, which has a completely separate address space.
You can obtain a piece of memory and address space in some other
process by calling the Win32 function VirtualAllocEx.
So that is where you must start.
Then the caller must write into that special memory, using WriteProcessMemory
If the memory is used to return data, it must be read with ReadProcessMemory
And the last thing you should do, once neither process needs
the special memeory any more, is use VirtualFreeEx to release that memory again.
Here are some code snippets that are part of the solution:
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern IntPtr VirtualAllocEx(int hProcess, int address,
int size, uint allocationType, uint protection);
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern bool VirtualFreeEx(int hProcess, IntPtr address,
int size, uint freeType);
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern bool WriteProcessMemory(int hProcess,
IntPtr otherAddress, IntPtr localAddress, int size,
ref uint bytesWritten);
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern bool ReadProcessMemory(int hProcess,
IntPtr otherAddress, IntPtr localAddress, int size,
ref uint bytesRead);
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern bool ReadProcessMemory(int hProcess,
IntPtr otherAddress, StringBuilder localAddress, int size,
ref uint bytesRead);
public void Read(object obj, int size, IntPtr ptr) {
uint bytesRead=0;
GCHandle handle=GCHandle.Alloc(obj, GCHandleType.Pinned);
IntPtr objPtr=handle.AddrOfPinnedObject();
if (!ReadProcessMemory(hProcess, ptr, objPtr, size, ref bytesRead)) {
int err=GetLastError();
env.error("Read failed; err="+err+" bytesRead="+bytesRead);
}
handle.Free();
}
public string ReadString(int size, IntPtr ptr) {
StringBuilder sb=new StringBuilder(size);
uint bytesRead=0;
if (!ReadProcessMemory(hProcess, ptr, sb, size, ref bytesRead))
env.error("Read failed; bytesRead="+bytesRead);
return sb.ToString();
}
public void Write(object obj, int size, IntPtr ptr) {
uint bytesWritten=0;
GCHandle handle=GCHandle.Alloc(obj, GCHandleType.Pinned);
IntPtr objPtr=handle.AddrOfPinnedObject();
if (!WriteProcessMemory(hProcess, ptr, objPtr, size, ref bytesWritten))
env.error("Write failed; bytesWritten="+bytesWritten);
handle.Free();
}
Dont mind the env.log and env.error, those are just log functions. You can substitute
your own if required. And you might want to throw an exception when an error occurs.
Hope this helps.
Luc Pattyn
|
|
|
|
|
On the other hand, if you can fit all the required data in lParam (32-bit), then you
make it so that you dont need pointers at all.
Some of the Window messages are known to contain a point in lParam, using the high and
low 16 bits for x and y (or is it y and x, dont recall).
Since I am not familiar with message 789 I can't tell if this is applicable to you.
If you defined it, and are responsible for the code in both processes,
I suggest the simple way described above !
Luc Pattyn
|
|
|
|
|
Hi, I am trying to drive Source Safe from my own front end.
I can't manage to create a new directory in VSS (Not a Directory on my PC)
I am using the Interop.SourceSafeTypeLib would another library be any better?
Thanks
Elephant
|
|
|
|
|
Have you tried VSSItem.NewSubproject ?
|
|
|
|
|
Hi all!
I use your help very urgent!
2 years ago a remote application was created.
The DataService (DataService.dll) contains a IRemoteFactory, which
allows the client to get access to the corresponding interface (here
the implementation):
public sealed class VRemoteFactory : MarshalByRefObject,
IRemoteFactory {
private DataObject m_DataObj = null;
public IDataObject iDataObject {
get {
if (null == m_DataObj) {
m_DataObj = new DataObject();
}
return m_DataObj;
}
}
The class DataObject (implemented as MarshalByRefObject in the
DataService.dll) implements the IDataObject interface, which provides a
property 'Version' and a function to get an object of the class Data
(implemented as sealed Serializable).
Now I have to extend the DataService.
As described in the .NET Remoting book of Ingo, I created a new
interface IExtendedDataObject which inherits from IDataObject. The
DataObject class now implements IExtendedDataObject, with the new
property that returns a class ExtData (which inherits from Data (which
is no longer declared as sealed)). I did not change anything at the
VRemoteFactory.
So every thing works fine as long as I use the new addapted client with
the new DataService (DataServer.exe). But if I try to run my new Client
againts the old DataService (DataServer.exe) I get a
InvalidCastException (Return argument has invalid type), but I do not
know why ??? I get this exception as soon as I call the
IRemoteFactory.iDataObject in the client, but why ???
In a demo project every thing works!!!
Please help me!
PS: I read something about namespace clashes if the old version is
compiled in .NET 1.0 and the new in 1.1. ????
Thanks
|
|
|
|
|
Hello!
I want to be able to change color of tabpages in a tabcontrol. Ive heard it´s got to do with drawmode, but I can´t figure out what to do. How do I achieve this?
|
|
|
|
|
Hi,
You can try to create a new class that inherits from TabPage. In this class you can make an override of the function OnPaint and use the PaintEventArgs parameter of this method to draw.
Then in your tabcontrol, instead of adding tabpages, you must add your new class.
|
|
|
|
|
Hi
You can just set the BackColor like so:
MyTabPage.BackColor = Color.Aquamarine;
HTH HN3
|
|
|
|
|
Set the TabControl's DrawMode to OwnerDraw, and then handle the DrawItem event to draw things yourself.
private void tagpage2_DrawItem(sender object, Eventarg e)
{
//here is place to write ur code using System.graphics
}
|
|
|
|
|
|