|
Hello everyone,
Something I've wondered about for some time: If I add a file (Any file, say Settings.Xml - I don't want to use MyApplication.Settings.XXX here) to my project in Visual Studio and I want to open it, how do I do this?
The following looks just plain awful:
Using X As New FileStream(Application.StartupPath & "/../../Settings.Xml", ...)
Since the startup path is /bin/debug/ this would work. But the moment I deploy my application somewhere, my Settings.Xml and executable should be in the same directory.
I could ofcourse put the files in the /bin/debug/ directory right away but that's not really elegant either is it.
Any ideas?
Cheers,
Wouter
|
|
|
|
|
Select the file in the Solution Explorer. Switch to the properties window. In the Copy to Output Directory dropdown select Copy Always.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yaye, that's it! Thanks Pete!
|
|
|
|
|
HI,
I've have a odbcDataAdapter
When i Drag&Drop it A wizard is Displayed
In The New Connection i Go To DataSource To Change it to odbc
but i do not have that option there.
i've got only :
Microsoft Access DataBase File
Microsoft Sql Server DataBase File
how can i add the odbc to the wizard???
i'm using MS Visual c# 2005 Express Edition
-- modified at 10:06 Wednesday 7th November, 2007
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: i'm using MS Visual c# 2005 Express Edition
You can't.
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
i have a problem with datagridview it's datasource is dataview
when i try to add new row in datagrid view it does not added
and this is my code
DV_Obligetory = DS_Subject.Tables["Subjects"].DefaultView;
DV_Obligetory.RowFilter = "Subject_Type='optional'";
DV_Obligetory.AllowDelete = true;
DV_Obligetory.AllowEdit = true;
DV_Obligetory.AllowNew = true;
BindingSource Binging=new BindingSource();
Binging.DataSource=DV_Obligetory;
Binging.AllowNew = true;
dg_obligatory.DataSource = Binging;
thnx 4 help
MD_NADA
|
|
|
|
|
I have a dataset in my Smart Device Application. On my panel I would like to add buttons for the navigation of the records in my dataset (Previous and Next record).
Does anyone have an example of code for dataset navigation?
Thanks in advance.
|
|
|
|
|
Create your back and next buttons, and In your form load have a int set to 0(call this rowCounter). When next is pressed, increment that variable, and loop thru a row(your rowCounter) and get all your columns, and display them how you want. When back is pressed decrement the rowCounter variable, and loop through that row and do what you will with the columns
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
hi all,
I have a listview in which i am trying to display thumbnail images along with text like the windows explorer.
I am able to display the thumbnail view with lots of help from members here. and i tried of sorting out the flickering problem in listview. but when i try to drag the vertical scrollbar down or up rather, the images are not aligned properly and it sort of is overwritten over one another.
here is the code i used for drawing the item(having set the owner draw property true).this is just a sample code with the controls having their default names.
private void listView1_DrawItem(object sender, System.Windows.Forms.DrawListViewItemEventArgs e)
{
if (imageList1.Images.Count > 0)
{
// Draw the item text for views other than the Details view.
if (listView1.View != View.Details)
{
//Image newimage = new Bitmap(imageList1.Images[e.ItemIndex]);
Image newimage = new Bitmap(imageList1.Images[0]);
left = e.Bounds.Left + 5;
top = e.Bounds.Y + this.Height / 7;
width = newimage.Width + 5;
height = newimage.Height - 25;
textbrush = new SolidBrush(Color.FromArgb(255, 236, 233, 216));
Rectangle text_rect = new Rectangle(left, top, width, height);
text = e.Item.Text;
DrawRoundedRectangle(e.Graphics, new Pen(textbrush), Color.White, text_rect, new Size(8, 8), newimage, text);
left = left + 20;
top = top + 130;
text_rect = new Rectangle(left - 5, top - 25, width - 30, 20);
DrawRoundedRectangle(e.Graphics, new Pen(new SolidBrush(Color.White)), Color.White, text_rect, new Size(1, 1), null, text);
listView1.EnsureVisible(e.ItemIndex);
}
}
}
public void DrawRoundedRectangle(Graphics g, Pen p, Color backColor, Rectangle rc, Size size, Image img, string text)
{
Point[] points = new Point[8];
//prepare points for poligon
points[0].X = rc.Left + size.Width / 2;
points[0].Y = rc.Top + 1;
points[1].X = rc.Right - size.Width / 2;
points[1].Y = rc.Top + 1;
points[2].X = rc.Right;
points[2].Y = rc.Top + size.Height / 2;
points[3].X = rc.Right;
points[3].Y = rc.Bottom - size.Height / 2;
points[4].X = rc.Right - size.Width / 2;
points[4].Y = rc.Bottom;
points[5].X = rc.Left + size.Width / 2;
points[5].Y = rc.Bottom;
points[6].X = rc.Left + 1;
points[6].Y = rc.Bottom - size.Height / 2;
points[7].X = rc.Left + 1;
points[7].Y = rc.Top + size.Height / 2;
//prepare brush for background
Brush fillBrush = new SolidBrush(backColor);
//draw side lines and circles in the corners
g.DrawLine(p, rc.Left + size.Width / 2, rc.Top,
rc.Right - size.Width / 2, rc.Top);
g.FillEllipse(fillBrush, rc.Right - size.Width, rc.Top,
size.Width, size.Height);
g.DrawEllipse(p, rc.Right - size.Width, rc.Top,
size.Width, size.Height);
g.DrawLine(p, rc.Right, rc.Top + size.Height / 2,
rc.Right, rc.Bottom - size.Height / 2);
g.FillEllipse(fillBrush, rc.Right - size.Width, rc.Bottom - size.Height,
size.Width, size.Height);
g.DrawEllipse(p, rc.Right - size.Width, rc.Bottom - size.Height,
size.Width, size.Height);
g.DrawLine(p, rc.Right - size.Width / 2, rc.Bottom,
rc.Left + size.Width / 2, rc.Bottom);
g.FillEllipse(fillBrush, rc.Left, rc.Bottom - size.Height,
size.Width, size.Height);
g.DrawEllipse(p, rc.Left, rc.Bottom - size.Height,
size.Width, size.Height);
g.DrawLine(p, rc.Left, rc.Bottom - size.Height / 2,
rc.Left, rc.Top + size.Height / 2);
g.FillEllipse(fillBrush, rc.Left, rc.Top,
size.Width, size.Height);
g.DrawEllipse(p, rc.Left, rc.Top,
size.Width, size.Height);
//fill the background and remove the internal arcs
g.FillPolygon(fillBrush, points);
if (img != null)
{
g.DrawImage(img, rc.Left + 15, rc.Top + 10, 80, 80);
}
else
{
StringFormat stringFormat = new StringFormat();
stringFormat.Trimming = StringTrimming.EllipsisCharacter;
stringFormat.FormatFlags = StringFormatFlags.NoWrap;
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
Rectangle text_rec = new Rectangle(rc.Left, rc.Top, rc.Width, rc.Height);
g.DrawString(text, f, new SolidBrush(Color.DimGray), text_rec, stringFormat);
}
//dispose the brush
fillBrush.Dispose();
}
can anybody tell me Where i am going wrong?
any suggestions on how to solve it?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
anu81 wrote: but when i try to drag the vertical scrollbar down or up rather, the images are not aligned properly and it sort of is overwritten over one another.
I didn't really look much thru the code, but here's what I suggest you try doing: In the listview events, find something for vertical scroll. When the event has finished, re-draw your images using the new coordinates of your object.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
anu81 wrote: Image newimage = new Bitmap(imageList1.Images[0]);
I assume imageListI.Images contains images, so why do you create a new Image here?
Can't you do just Image newimage = imageList1.Images[e.ItemIndex]; ?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
how we can create a datareader from a datatable. please suggest any way to solve this problem.
|
|
|
|
|
DataTable dt = new DataTable();
DataTableReader dr = new DataTableReader(dt);
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
A datareader from a datatable? Are you talking about System.Data.DataTable class?? If its your case I suggest two ways:
1.Make a forecach loop through DataTable.Rows and make anything foreach row.
2.To complement the upper suggestion use DataTable.Select('where clause') and store DataRow[] result in a var and make a foreach loop on this DataRow[].
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
Hi,
I doesn't have much to do with C#, anyway, I'm looking for a good free .MSI creator to publish (install) .NET project I'm working on.
Do you know any?
thanx
zilo
|
|
|
|
|
Do you know IIS(Inno Setup)? Its free and use extended...
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
I always use the Visual Studio Setup Installation package. Or perhaps you were talking about something else?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
VS Setup Installation lacks many features that I need. Custom prerequisites, multiple language support, writing into Registry, custom actions.
zilo
|
|
|
|
|
Zilo(svk) wrote: VS Setup Installation lacks many features that I need. Custom prerequisites, multiple language support, writing into Registry, custom actions.
I recently had the same problem, I needed to do every thing you listed. I did all by using the VS setup package. Both of the articles below have examples on how to tackle all of the issues you listed
http://www.codeproject.com/install/shortcut_installer.asp[^]
http://www.codeproject.com/install/SetupAndDeployment.asp[^]
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi.
First of all thanx for tips.
How can I translate installation package into other language than those that are in Localization Property of Deployment Project Properties? I can't figure it out...
zilo
|
|
|
|
|
How about WiX (Windows Installer XML). Its free and MS uses it for installers such as Office 2007.
Hogan
|
|
|
|
|
thanx for all tips
zilo
|
|
|
|
|
Hi,
I need to Restrict Copy Access for a Folder and the Files in it. I will be given a File with MyEncriptedFile.MyExtension . When the User clicks on it, it is decripted ,saved in a folder and Opened automatically.
The file say if it is a PDF file the user should not be able to copy it using File->save as option. Iam able to set permissions for a folder.
by creating the directory as below using managed C++.
DirectoryInfo^ dsInfo = gcnew DirectoryInfo(strdirpath);
DirectorySecurity^ ds = gcnew DirectorySecurity();
ds->AddAccessRule(gcnew FileSystemAccessRule(struserName,FileSystemRights::Delete|FileSystemRights::DeleteSubdirectoriesAndFiles|FileSystemRights::CreateFiles, AccessControlType::Allow));
dsInfo->Create(ds);
After setting these permissions I can access the folder only Programmatically and not by clicking. I created a PDF file in that folder Programmatically and opened it. Now, Iam unable to restrict the file from copying .
FileInfo^ filInfo = gcnew FileInfo(m_strFilePath);
FileSecurity^ filsec = gcnew FileSecurity();
filsec->AddAccessRule(gcnew FileSystemAccessRule(m_strUserName,FileSystemRights::Traverse, AccessControlType::Allow));
fs = filInfo->Create();
What are the Permissions I should be giving in FileSystemRights for restricting my file from getting copied?
Any suggestions would be helpful.
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
You may want to ask this on a C++ forum. This one's for C#.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All,
Could you please help me to why we write IE tool bar in VS.Net 2008. Is it has any build-in class support. Please suggest some articles.
I have article, which developped in 2003. But want's to know any built in support in VS.Net 2008.
Thanks in advance.
srinivas
|
|
|
|
|