|
I am somewhat young in C# but what has worked for me is to add a context menu to the button.
|
|
|
|
|
Hi,
I want make;
For instance I have a on web service function A(File myFile). I want to send
the file abc.xml to A function and want to read the content of abc.xml from
inside of A function with XmlTextReader(File). How can I do this?
Any help would be appriciated,
Kind Regards,
Arda
-
When in doubt, push a pawn!
-
|
|
|
|
|
I think you should pass the xml as a Stream (memoryStream), so you function should look like this
function_A(Stream myXMLData)
and call the XmlTextReader with the stream
XmlTextReader(myXMLData)
I hope you understand...
|
|
|
|
|
vladstanciu wrote:
I think you should pass the xml as a Stream (memoryStream), so you function should look like this
function_A(Stream myXMLData)
and call the XmlTextReader with the stream
XmlTextReader(myXMLData)
Not on a webservice. Just pass as a string.
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi All,
I have DataGrid and Save button, problem is if i make changes on current record and press save button , datagrid is not update, but if i make changes and go to next record and then press save button my datagrid is updated ???
I find somewhere that I need to add in my code EndEdit, but because I’m beginner in C# ,I don’t know where and on what I need to include that part. Here is my code on save button:
<br />
private void btnSave_Click(object sender, System.EventArgs e)<br />
{<br />
try <br />
{<br />
DataSet changedData = dsVessCert.GetChanges();<br />
if (changedData != null)<br />
{<br />
int numRows = adVessCert.Update(changedData);<br />
MessageBox.Show("Database updated " + numRows + " rows successfuly", "Success");<br />
dsVessCert.AcceptChanges();<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in Update: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
dsVessCert.RejectChanges();<br />
}<br />
}<br />
Thanks
|
|
|
|
|
You will need to call the EndCurrentEdit() method of the BindingManager of the datagrid (or something like that, its a bit sneaky to find).
top secret xacc-ide 0.0.1
|
|
|
|
|
set the EditItemIndex to -1 and Bind Data to DataGrid in the end of your btnSave_Click method.
Like- add these lines to your btnSave_Click method.
YourDataGrid.EditItemIndex = -1;
YourDataGrid.DataBind();
Hope it helps.
JAT
Hamilton, NJ
|
|
|
|
|
What you posted is for ASP.NET (there is no DataGrid.DataBind defined for System.Windows.Forms.DataGrid ). Things work much differently in Windows Forms in contrast to ASP.NET. The previous post (before yours) was correct.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
Hello
I have a project that uses a login form and when the user clicks enter it opens another form called customers.
I have this code in the login form.
static void Main()
{
Application.Run(new frmlogin());
}
The problem is when l click enter on the login form to show the customers form. I want to close the login form using this.Close(); but when l do this it exits the entire project.
I have used this.Visible = false; But then l can't exit the entire project as the form is invisible.
I think want l really want to do is allow the user to login then close this form, as it is not needed anymore. When the user has finished with the application, they can click on the exit button on the customers form to exit the entire project.
Any easy way to do this.
Thanks in advance.
Steve
|
|
|
|
|
I think you're better off if you use this.Hide() on the login form (same as this.Visible = false). and when the Exit button is clicked or
private override void OnClosing(CancelEventArgs e);
raise and event in the customers form. Catch it in the login form and then use this.Close();
|
|
|
|
|
You're coming from VB6, right?
I'd say the correct way to do this would be something like:
static void Main()
{
FrmLogin login = new FrmLogin();
DialogResult res = login.ShowDialog();
if (res == DialogResult.OK)
{
Application.Run(new MainFormOfYourApp());
}
}
Regards,
mav
|
|
|
|
|
if i use this method in smartdevice application, my mainform might not be able to close..
|
|
|
|
|
I just tried it and found the main application form not appearing, although the app _was_ running...
But by using ShowDialog() on the new MainFrame instance instead of Application.Run() I could achieve the desired behaviour in a mobile application as well.
Regards,
mav
|
|
|
|
|
I'm trying to get DrawItem and MeasureItem working on a ListView, with a view to drawing items in LargeIcon view. I've managed to get DrawItem working okay, using the code below. My problem is with the MeasureItem event. The event is only ever called once, and most annoyingly, are never called when the view isn't the details view.
I've tinkered about with the owner-drawn listview projects on codeproject.com, and have discovered you need to handle ITEMPREPAINT for non-details view listviews. The problem with this is, MeasureItem isn't supported (or rather, I don't know how to handle it), and so you end up having to handle or Mouse events yourself.
This removes the point of the control being derived from ListView - to utilise all the functionality a listview has in.
I also tried creating ListViewItemCollections and ListViewItems myself, but gave up with that as I was getting nowhere.
Hopefully you've read to this stage and haven't dropped off. If anyone can suggest controls, websites, FAQs etc. that'd be appreciated.
Cheers
..................................................
The code:
public class MyListView : ListView
{
private struct MEASUREITEMSTRUCT
{
public int CtlType;
public int CtlID;
public int itemID;
public int itemWidth;
public int itemHeight;
public IntPtr itemData;
}
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
private struct DrawItemStruct
{
public int ctlType;
public int ctlID;
public int itemID;
public int itemAction;
public int itemState;
public IntPtr hWndItem;
public IntPtr hDC;
public RECT rcItem;
public IntPtr itemData;
}
private enum ReflectedMessages
{
OCM__BASE = (0x0400 + 0x1c00),
OCM_DRAWITEM = (OCM__BASE + 0x002B),
}
public event System.Windows.Forms.DrawItemEventHandler DrawItem;
public event MeasureItemEventHandler MeasureItem;
public const int LVS_OWNERDRAWFIXED = 0x0400;
private DrawMode drawMode;
public MyListView()
{
this.drawMode = DrawMode.Normal;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= (drawMode != DrawMode.Normal) ? LVS_OWNERDRAWFIXED : 0;
return cp;
}
}
public virtual DrawMode DrawMode
{
get { return drawMode; }
set { drawMode = value; }
}
protected virtual void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
{
}
public virtual void OnMeasureItem(MeasureItemEventArgs e)
{
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case (int)ReflectedMessages.OCM_DRAWITEM:
{
DrawItemStruct dis =
(DrawItemStruct)m.GetLParam(typeof(DrawItemStruct));
Graphics graph = Graphics.FromHdc(dis.hDC);
Rectangle rect = new Rectangle(dis.rcItem.left,dis.rcItem.top,dis.rcItem.right - dis.rcItem.left,dis.rcItem.bottom - dis.rcItem.top);
int index = dis.itemID;
DrawItemState state = DrawItemState.None;
System.Windows.Forms.DrawItemEventArgs e = new System.Windows.Forms.DrawItemEventArgs(graph, Font, rect, index, state, ForeColor, BackColor);
if ( this.DrawItem != null )
{
this.DrawItem(this,e);
}
OnDrawItem(e);
graph.Dispose();
break;
}
case 8236:
this.WmReflectMeasureItem(ref m);
break;
}
}
private void WmReflectMeasureItem(ref Message m)
{
Graphics graphics1;
MeasureItemEventArgs args1;
MEASUREITEMSTRUCT measureitemstruct1 = (MEASUREITEMSTRUCT) m.GetLParam( typeof(MEASUREITEMSTRUCT) );
if ((this.drawMode == DrawMode.OwnerDrawVariable) && (measureitemstruct1.itemID >= 0))
{
graphics1 = Graphics.FromHwnd(this.Handle);
args1 = new MeasureItemEventArgs(graphics1, measureitemstruct1.itemID, 20);
try
{
if ( this.MeasureItem != null )
{
this.MeasureItem(this,args1);
}
this.OnMeasureItem(args1);
measureitemstruct1.itemHeight = args1.ItemHeight;
}
finally
{
graphics1.Dispose();
}
}
measureitemstruct1.itemHeight = 20;
Marshal.StructureToPtr(measureitemstruct1, m.LParam, false);
m.Result = ((IntPtr) 1);
}
}
|
|
|
|
|
Hi there:
I wanna add some facility to my app. & need to have next conntol name.
I met GetNextControl but I couldnt work with that.
I couldnt sauced useing ctl
Can anybody help me, Tnx in advance.
Always ,
Hovik Melkomian.
|
|
|
|
|
|
I couldnt work with it & no document or sample I could find.
I need to skip the control as user press TAB. thats it.
Always ,
Hovik Melkomian.
|
|
|
|
|
Hovik Melkomian wrote:
I need to skip the control as user press TAB. thats it.
If you want to skip a control when the TAB key is pressed, first be sure that the control does not accept TABs (like a text box), and if it does make sure it doesn't (there are properties for that), and second make the "TAB order" into the form so the control succed each others like the way you want
I hope you understand...
|
|
|
|
|
Hello !
I'm trying to use a web custom control compiled in vb.net in my c# application. But i get a compilation error at run-time. When using the same web custom control in a vb project, i have no problem at all.
Error message
CS0234: The type or namespace name 'Application_Header' does not exist in the class or namespace 'Application_Header.Application_Header' (are you missing an assembly reference?)
note: the namespace i used is referenced in References and also with the using statement.
Does anyone have an idea , because i'm lost and i'd rather not start developping in vb.
Thanks
|
|
|
|
|
|
hi,
is there any embedded database used by desktop applications other than MSDE?
thanks
|
|
|
|
|
Try googling SQL Lite, which comes with an odbc driver, and also a native .net driver for it.
|
|
|
|
|
There is also the Firebird database project.
http://firebird.sourceforge.net/
It has a .Net provider and also an embedded version. And the price is right.
Steve Maier, MCSD MCAD
|
|
|
|
|
|
Hy everyone!
I want to change the icon of my WindowsForms Window and my notifyicon depending on the system state meaning, if the apllication is able to do a special kind of work then the icon is style A, if it fails then it changes to style B. If the user tries again and this time it works then the icon changes back to style A.
In general:
application works correctly => icon A
application fails => icon B
application works correctly (after having failed before) => icon changes from B to A.
Well how do I realize this in my application? I know there is something like notify.Icon but there it says for example
this.tbiNameKeyService.Icon = ((System.Drawing.Icon)(resources.GetObject("tbiNameKeyService.Icon")));
at the moment I have no idea
1) where the application chooses to use my icon I assigned in the properties
2) how to change/switch the icon depending on the state (ok/failure) because of 1)
I mean I could have tried to use an absolute link to the file but then my application is fixed to this configuration. But I want it not to be absolute! Meaning I do want to being able to "port" it to another computer.
Thanks!
Stephan.
|
|
|
|