|
Hi Sir and Madam,
How to draw rounded rectangle?
Thank You.
|
|
|
|
|
I seem to recall writing an article on how to do it, did you try searching the site ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Try Following.
Good Luck.
float radius = 5; // Radius for round curve
float diameter = 2 * radius;
// Basic dimensions where Roundrect is to be drawn
Rectangle BaseRect = new Rectangle(x1, y1, x2, y2);
SizeF RoundSize = new SizeF(diameter, diameter);
RectangleF RoundArc = new RectangleF(BaseRect.Location, RoundSize);
// Graphics object
Graphics G = Graphics.FromHwnd(this.Handle);
// Create Graphics path
GraphicsPath Gp = new GraphicsPath();
Pen P = new Pen(Brushes.Black);
// Top left arc
RoundArc.X = BaseRect.Left;
RoundArc.Y = BaseRect.Top;
Gp.AddArc(RoundArc, 180, 90);
//Top right arc
RoundArc.X = (BaseRect.Right - diameter);
RoundArc.Y = BaseRect.Top;
Gp.AddArc(RoundArc, 270, 90);
// Bottom right arc
RoundArc.X = (BaseRect.Right - diameter);
RoundArc.Y = BaseRect.Bottom - diameter;
Gp.AddArc(RoundArc, 0, 90);
// Bottom left arc
RoundArc.X = BaseRect.Left;
RoundArc.Y = (BaseRect.Bottom - diameter);
Gp.AddArc(RoundArc, 90, 90);
// Close Graphics path
Gp.CloseFigure();
// Draw graphics path
G.DrawPath(P, Gp);
|
|
|
|
|
i want to display some custom properties in propertygrid
Like...(1)Job :Engineer,Doctor,Teacher
(2)Class :I,II,III
I am using typeconverters like ACTDropDown derived from StringConvertor.How will i use the same class for both the purpose i.e for displaying Job& Class dropdowns separately.
|
|
|
|
|
Hi,
If you have knowledge in active directory keep reading and answer please,
I need to know how to add a user to a group in active directory.
Give me code please
Best regards
|
|
|
|
|
|
Hi all
I had created one windows service with VS2005 (C#) and installed that one in my local system with InstallUtil.Exe. The installations are completed Successfully, but i am not getting that service in service window (Computer Management , Service Window)
Can any one tel me the reason
Thanx
nidheesh
|
|
|
|
|
Hi,
I'm in need of populating the selected datagrid row in the respective fields in the form for updating the values.I have 3 levels in datagrid interlinked with parent - child relationships.As of now,I level is populating fine.But II level can have n number of records.When I'm selecting the II level,I couldn't be able to populate(I'm not getting any exception,But the Form is retaining the I level values.)
I'm herewith giving the mwthods that I'm using!
Please,let me know How should I approach!
I'm stuck up here!
private void DisplayDataList(string vstrProductCode)
{
StringBuilder stbSQLStatement0 = new StringBuilder();
stbSQLStatement0.Append("SELECT B.[ProductCode] ");
stbSQLStatement0.Append(" ,B.[ProductDesc] ");
stbSQLStatement0.Append(" ,SUM(A.QtyIn) As [In] ");
stbSQLStatement0.Append(" ,SUM(A.QtyOut) As [Out] ");
stbSQLStatement0.Append(" ,SUM(A.QtyIn) - SUM(A.QtyOut) As [BalBillQty] ");
stbSQLStatement0.Append(" ,(SUM(A.QtyIn) - SUM(A.QtyOut)) * Avg(B.ConvFactor) As [BalReportQty] ");
stbSQLStatement0.Append("FROM [MARTblInventory] As A WITH (NOLOCK) ");
stbSQLStatement0.Append(" INNER JOIN [MARTblProduct] As B WITH (NOLOCK) ");
stbSQLStatement0.Append(" ON A.ProductCode = B.ProductCode ");
stbSQLStatement0.Append(" and A.MarketSegID = B.MarketSegmtID ");
stbSQLStatement0.Append(" and A.SourceID = B.SourceID ");
if (! vstrProductCode.Equals(""))
{
stbSQLStatement0.Append("WHERE B.[ProductCode] LIKE '" + vstrProductCode + "%' ");
}
stbSQLStatement0.Append("GROUP BY B.[ProductCode] ");
stbSQLStatement0.Append(" ,B.[ProductDesc] ");
DataSet dtsResult0 = new DataSet();
dtsResult0 = QueryData(stbSQLStatement0.ToString());
StringBuilder stbSQLStatement1 = new StringBuilder();
stbSQLStatement1.Append("SELECT A.InvRefID ");
stbSQLStatement1.Append(" ,A.EntryDate ");
stbSQLStatement1.Append(" ,B.[ProductCode] ");
stbSQLStatement1.Append(" ,B.[ProductDesc] ");
stbSQLStatement1.Append(" ,A.[ReferenceNo] ");
stbSQLStatement1.Append(" ,A.QtyIn As [In] ");
stbSQLStatement1.Append(" ,A.QtyOut As [Out] ");
stbSQLStatement1.Append(" FROM [MARTblInventory] As A WITH (NOLOCK) ");
stbSQLStatement1.Append(" INNER JOIN [MARTblProduct] As B WITH (NOLOCK) ");
stbSQLStatement1.Append(" ON A.ProductCode = B.ProductCode ");
stbSQLStatement1.Append(" and A.MarketSegID = B.MarketSegmtID ");
stbSQLStatement1.Append(" and A.SourceID = B.SourceID ");
if (! vstrProductCode.Equals(""))
{
stbSQLStatement1.Append("WHERE B.[ProductCode] LIKE '" + vstrProductCode + "%' ");
}
DataSet dtsResult1 = new DataSet();
dtsResult1 = QueryData(stbSQLStatement1.ToString());
StringBuilder stbSQLStatement2 = new StringBuilder();
stbSQLStatement2.Append("SELECT A.InvRefID ");
stbSQLStatement2.Append(" ,B.PackageNo ");
stbSQLStatement2.Append(" ,B.Length ");
stbSQLStatement2.Append(" ,B.Area ");
stbSQLStatement2.Append(" ,B.ReferenceNo ");
stbSQLStatement2.Append("FROM [MARTblInventory] As A WITH (NOLOCK) ");
stbSQLStatement2.Append(" INNER JOIN [MARTblInventoryPkgDetail] As B WITH (NOLOCK) ");
stbSQLStatement2.Append(" ON A.InvRefID = B.InvRefID ");
if (! vstrProductCode.Equals(""))
{
stbSQLStatement2.Append("WHERE A.[ProductCode] LIKE '" + vstrProductCode + "%' ");
}
DataSet dtsResult2 = new DataSet();
dtsResult2 = QueryData(stbSQLStatement2.ToString());
DataSet dtsCombine = new DataSet();
dtsCombine.Tables.Add(dtsResult0.Tables[0].Copy());
dtsCombine.Tables[0].TableName = "Product";
if (dtsResult1.Tables[0].Rows.Count > 0)
//foreach(DataRow dr in dtsResult1.Tables[0].Rows)
{
dtsCombine.Tables.Add(dtsResult1.Tables[0].Copy());
dtsCombine.Tables[1].TableName = "ProductDetail";
dtsCombine.Relations.Add("ProductDetail",
dtsCombine.Tables["Product"].Columns["ProductCode"],
dtsCombine.Tables["ProductDetail"].Columns["ProductCode"]);
if (dtsResult2.Tables[0].Rows.Count > 0)
{
dtsCombine.Tables.Add(dtsResult2.Tables[0].Copy());
dtsCombine.Tables[2].TableName = "PackageDetail";
dtsCombine.Relations.Add("PackageDetail",
dtsCombine.Tables["ProductDetail"].Columns["InvRefID"],
dtsCombine.Tables["PackageDetail"].Columns["InvRefID"]);
}
ugdDataList.Text = mstrGridName;
ugdDataList.DataSource = dtsCombine;
ugdDataList.DataBind();
if (ucbProductCode.Text != "")
SeekTheSelectedRowInGrid(ucbProductCode.Text);
}
SetControlForMaintenance(CWinMaintainCln.MaintenanceMode.enmBlank);
pnlDataHeader.Visible = false;
}
private void DisplayDataDetail(string vstrDataKeyName)
{
StringBuilder stbSQLStatement0 = new StringBuilder();
stbSQLStatement0.Append("SELECT A.InvRefID ");
stbSQLStatement0.Append(" ,B.[ProductCode] ");
stbSQLStatement0.Append(" ,B.[ProductDesc] ");
stbSQLStatement0.Append(" ,A.ReferenceNo ");
stbSQLStatement0.Append(" ,A.Remarks ");
stbSQLStatement0.Append(" ,A.TransTypeID ");
stbSQLStatement0.Append(" ,A.QtyIn ");
stbSQLStatement0.Append(" ,A.QtyOut ");
stbSQLStatement0.Append(" ,A.EntryDate ");
stbSQLStatement0.Append("FROM [MARTblInventory] As A WITH (NOLOCK) ");
stbSQLStatement0.Append(" INNER JOIN [MARTblProduct] As B WITH (NOLOCK) ");
stbSQLStatement0.Append(" ON A.ProductCode = B.ProductCode ");
stbSQLStatement0.Append(" and A.MarketSegID = B.MarketSegmtID " );
stbSQLStatement0.Append(" and A.SourceID = B.SourceID ");
stbSQLStatement0.Append("WHERE A.ProductCode = '" + vstrDataKeyName + "' ");
//stbSQLStatement0.Append("Where A.InvRefID = '" + vstrDataKeyName + "' ");
DataSet dtsResult = new DataSet();
dtsResult = QueryData(stbSQLStatement0.ToString());
UltraGridRow activeRow = this.ugdDataList.ActiveRow;
lblInvRefID.Text = dtsResult.Tables[0].Rows[0]["InvRefID"].ToString();
ucbProductCode.Text = dtsResult.Tables[0].Rows[0]["ProductCode"].ToString();
lblProductDescDisplay.Text = dtsResult.Tables[0].Rows[0]["ProductDesc"].ToString();
txtReferenceNo.Text = dtsResult.Tables[0].Rows[0]["ReferenceNo"].ToString();
ucbTransactionType.Value = dtsResult.Tables[0].Rows[0]["TransTypeID"].ToString();
txtRemarks.Text = dtsResult.Tables[0].Rows[0]["Remarks"].ToString();
uneQuantityInDisplay.Value = double.Parse(dtsResult.Tables[0].Rows[0]["QtyIn"].ToString());
DateTime dtmEntryDate = new DateTime();
dtmEntryDate = Convert.ToDateTime(dtsResult.Tables[0].Rows[0]["EntryDate"].ToString());
if (dtmEntryDate.Year == 1900)
{
dtpDate.Checked = false;
}
else
{
dtpDate.Checked = true;
dtpDate.Value = dtmEntryDate;
}
StringBuilder stbSQLStatement1 = new StringBuilder();
stbSQLStatement1.Append("SELECT A.InvRefID ");
stbSQLStatement1.Append(" ,B.PackageNo ");
stbSQLStatement1.Append(" ,B.Length ");
stbSQLStatement1.Append(" ,B.Area ");
stbSQLStatement1.Append(" ,B.ReferenceNo ");
stbSQLStatement1.Append("FROM [MARTblInventory] As A WITH (NOLOCK) ");
stbSQLStatement1.Append(" INNER JOIN [MARTblInventoryPkgDetail] As B WITH (NOLOCK) ");
stbSQLStatement1.Append(" ON A.InvRefID = B.InvRefID ");
stbSQLStatement1.Append("WHERE A.InvRefID = " + lblInvRefID.Text + " ");
DataSet dtsResult1 = new DataSet();
dtsResult1 = QueryData(stbSQLStatement1.ToString());
dtsResult1.Tables[0].TableName = "Add new Package Detail";
ugdPackageDetail.DataSource = dtsResult1.Tables[0];
ugdPackageDetail.DataBind();
if (mblnIsRowSelected)
SetControlForMaintenance(CWinMaintainCln.MaintenanceMode.enmReady);
}
Thank you,
Deepa
Be the Change You Want to See!
|
|
|
|
|
Can anyone help me. The solutions to the following questions are proving quite difficult to find from books and references.
1. How do I associate different data sources to each row of a datagrid control?
2. I would like the data grid to have both a customized vertical header (at the top) and a customized horizontal header (in the rightmost column)
3. Finally, how do I perform calculations to the dataset. For example, I would like to programmatically sort the rows according to the 3rd column. Or calculate the average of the 1st column and other adhoc calculations. I'd imagine there'd be built-in functionalities rather than copying the dataset to a linked-list/array/other custom container class and do the calculations from there.
Look forward to hearing from anyone. Thanks in advance.
cheers!
|
|
|
|
|
1) Not possible
2) Override ItemCreated or DataBind events and add the column to each row
or iterate through the datatable before it is bound to the control and add the column.
3) DataTable.Compute("Avg(col1)");
only two letters away from being an asset
|
|
|
|
|
j11Software wrote: I would like to programmatically sort the rows according to the 3rd column
You can do this by clicking the column header of your datagrid. Then you have to synchronize your dataset with the datagrid (this was the case 1.0, 1.1) I know there's a way by using key-pairs or something like that, but you could also cast the datagrid-view to a DataTable and work from there.
For average you'll have to do that manually I think. A count is dataset.Tables[0].Rows.Count;
Hope this helps
Good luck
|
|
|
|
|
Hi,
I have an instance of data table named Customers with the
columns "Name, Address, City, State, ZipCode",
sitting inside a dataset MyDataSet.
I have a BindingSource associated to the MyDataSet/Customers.
Without creating another instance of the table, I want to bind
it to a data grid view, and only have Name and Address columns
show up in the DataGridView.
One way I know I can do it is to do a Visible=false on DataBindingComplete event for columns
that I don't want displayed.
But I am trying to avoid all that unnecessary adding of columns
and hiding them when my requirement is to not deal with those columns
at all.
Just wondering if there is a way to bind a DataGridView to an
already available instance of a DataTable and limit the databinding
to only specific columns?
I appreciate you all sharing any insights regarding this.
-Athadu
|
|
|
|
|
Hello,
Is it possible to write action script in C#. Actually I want to stream video using Flash Communication Server. Now I want to stream video to another c# application on a different computer or to the web. Sorry if I wasn't clear. Please if someone could help me, it would be greatly appreciated. Thanks.
|
|
|
|
|
|
I have a variable number of DropDownList controls inside a Datalist control. This variability depends of the number of records in a DataTable.
I would be grateful if someone could tell me how to create ListItem controls accordingly with the data contained in a DataTable.
Here are the 4 possible ListItem controls to be inserted:
<asp:ListItem Value="blue" >Blue</asp:ListItem>
<asp:ListItem Value="red" >Red</asp:ListItem>
<asp:ListItem Value="black" >Black</asp:ListItem>
<asp:ListItem Value="white" >white</asp:ListItem>
For instance, if a product is manufactured with one of two colors ( let’s say “red” and “white” ) then the DataTable contains these binary values: “false”, “true”,”false”,”true” or ( 0,1,0,1) in the parameters “showBlue”, “showRed”, “showBlack”, “showWhite” for the four ListItem controls. So, in this example, I would want to use these data to create only ListItem controls for the red and the white options.
How do that ?
Here are the relevant pieces of code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<asp:DataList ID="ProductsList" Runat="server" EnableViewState="False" Visible="false" >
<ItemTemplate>
. . .
<span class="Title">
Product: <%# Eval("Title") %>
</span>
</td>
</tr>
<tr>
<td align="center" width="250">
<span class="Colors">
<asp:DropDownList ID="ColorsList" OnSelectedIndexChanged="GetColor" runat="server">
</asp:DropDownList>
</span>
</td>
</tr>
. . .
</ItemTemplate>
</asp:DataList>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void InsertDataInDataList()
{
ProductsList.DataSource = UserAccess.UserProducts(Username);
ProductsList.DataBind();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Obs: The “UserAccess.UserProducts(Username)” method returns a DataTable with variable number of records.
|
|
|
|
|
hi
i was installed sqlServer 2005 management Studio Express on my Server and i want to connect from my app (in other computers) to this database,but when i want add datasource to my project and select Microsoft SqlServer and inter Server's Name + "\SQLEXPRESS", i can not connect to database's, and i don't know where does the problem.
can anybody show me how to solve this problem ?
thanks
|
|
|
|
|
hdv212 wrote: i was installed sqlServer 2005 management Studio Express on my Server and i want to connect from my app (in other computers) to this database
That is not a database server, that is a graphic interface to manage an SQL Server 2005 database server. If you want to connect to the database server you have to install the actual database server also.
---
b { font-weight: normal; }
|
|
|
|
|
Did you actually install the database itself?
|
|
|
|
|
This is a very complex question, so please bare with me.
I'm using VB.net and C# (both vs2003), on a Windows XP machine.
First off, I have some code that allows me to retrieve an IRichEditOle object from a rich text box. With this object, I can insert an object into a RichTextBox control. After inserting the object(s), I can then call GetObjectCount and GetObject to iterate through the Ole objects embedded within the RichTextBox. The code for retrieving the RichEditOle interface and for inserting and retrieving objects (the meat of the application) is written in C#.
I have also written a custom control that inherits from "System.Windows.Forms.Label" and also implements IOleObject. This code is in VB.NET. It is registered for COM Interop and the appropriat guids have been generated. Besides the basic Label functionality, it also eposes extra public properties (strings).
The idea is that a user would be able to insert this custom label control anywhere within a RichTextBox. It works. I can insert and remove multiple controls. I can iterate through the collection of controls in the RichTextBox, cast them back to the custom label, and access each of their properties. It seems to be working perfect.
However, when I save the RTF, and then try to reload, I completely lose the embedded information. Everything else is there, just no custom labels in the RichTextBox. I can open the RTF in Notepad and see that there is embedded information. It saved, but didn't load.
I'm thinking that at least part of my problem might be that I'm not implementing the correct interfaces to allow the custom label to persist itself within the RTB. It might also be that I'm not inserting the object correctly within the RTB. The insertion part is fairly straightforward though. I have a REOBJECT class that I populate and pass to the IRichEditOle::InsertObject(REOBJECT re) method
Here's some of the code:
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.OLE.Interop;
[StructLayout(LayoutKind.Sequential)]
public class REOBJECT
{
public int cbStruct = Marshal.SizeOf(typeof(REOBJECT)); // Size of structure
public int cp; // Character position of object
public Guid clsid; // Class ID of object
public IntPtr poleobj; // OLE object interface
public IStorage pstg; // Associated storage interface
public IOleClientSite polesite; // Associated client site interface
public Size sizel; // Size of object (may be 0,0)
public uint dvAspect; // Display aspect to use
public uint dwFlags; // Object status flags
public uint dwUser; // Dword for user's use
}
Then, the code for actually inserting (lots omitted for brevity):
ILockBytes pLockBytes;
CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);
IStorage pStorage;
StgCreateDocfileOnILockBytes(pLockBytes, (uint)(STGM.STGM_SHARE_EXCLUSIVE|STGM.STGM_CREATE|STGM.STGM_READWRITE), 0, out pStorage);
IOleClientSite pOleClientSite;
this.IRichEditOle.GetClientSite(out pOleClientSite);
Guid guid = new Guid();
oleObject.GetUserClassID(out guid);
OleSetContainedObject(oleObject, true);
REOBJECT reoObject = new REOBJECT();
reoObject.cp = this._richEdit.SelectionStart;
reoObject.clsid = guid;
reoObject.pstg = pStorage;
reoObject.poleobj = Marshal.GetIUnknownForObject(oleObject);
reoObject.polesite = pOleClientSite;
reoObject.dvAspect = (uint)DVASPECT.DVASPECT_CONTENT;
reoObject.dwFlags = (uint)REOOBJECTFLAGS.REO_BELOWBASELINE;
this.IRichEditOle.InsertObject(reoObject);
Marshal.ReleaseComObject(pLockBytes);
Marshal.ReleaseComObject(pOleClientSite);
Marshal.ReleaseComObject(pStorage);
}
Any help in solving this is GREATLY appreciated.
Thanks for looking,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Looks like I've stumped the experts.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
|
Thanks for the article, however, it isn't really what I'm looking for.
It does show a media player control within the RTB and how to access it, but that's not what I need.
I have a custom control written in vb.net that I can already insert into a RTB. It seems like I save it ok, but when I reload the document, the controls are gone. The data in the RTF is stripped out during the load method of the RTB.
I need to be able to save the RTF with the embedded controls (and maintain their state), then reload the RTF later with all of the controls intact.
My best guess now is that my custom control isn't implementing the correct interfaces, or isn't getting registered correctly.
Any help is appreciated.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Hi,
I needed a list view that was capable of showing multiple icons in the first column in details view. I managed to create this using owner draw and gdi+ and overall it was easy to do. The only problem I've run into is when the mouse cursor moves over a listview item for the first time, the listview attempts to redraw the item yet does not redraw any of the subitems.
This is an acknowledged bug with the control itself and is mentioned here: msdn library. The article also lists two workarounds, one of which isn't very effective, which I have tried. I was just wondering if anyone knew of another way to handle this issue?
Thanks.
|
|
|
|
|
Hi,
I find that I can drag an jpeg image from IE to MSWord document, but can't drag an image from IE to a c# window form which has already added with both the dragOver and dragDrop events. But I can drag an the image from MSWord document to the C# window form. Why ?
Summary for dragging and dropping jpeg image
1. from IE to C# window form : failed
2. from IE to MSWord : OK
3. from MSWord to C# Window form : OK
Thanks
|
|
|
|
|
What is the code in your DragDrop event?
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|