|
Just to let you know, here is a list of escape sequences you might want to use/avoid.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Is there a way for me to convert my existing C# files to have .designer.cs files? I am working on a very large project and this would be a very useful change to our project. Are there any articles explaining how to do this by hand if there is no automatic converter?
|
|
|
|
|
I've never seen one myself, unfortunately. You *could* write something that would do this: basically create a new file on disk in the same folder as the original file, scan that file for the Dispose and InitializeComponent methods, then move them to the designer file. Shouldn't be too difficult.
|
|
|
|
|
I'm drawing text using TextOut and when I required text to be vertical I needed to use LogFont to set the orientation. Hovever when texting it on the origional function I made everytime it draws it, its slightly different and reall messed up. Like it will be much bigger and italic and striked outdespite the LOGFONT object saying otherwise.
Here's an image of what it looks like: http://www.draders.com/images/CreateFontIndirect.jpg[^]
The function is:
public static void DrawString(Graphics g, string s, Font Font, Color ForeColour, int x, int y) {<br />
IntPtr hdc = g.GetHdc();<br />
LOGFONT LF = new LOGFONT();<br />
Font.ToLogFont(LF);<br />
<br />
IntPtr fntNew = CreateFontIndirect(ref LF);<br />
IntPtr fntOld = SelectObject(hdc, fntNew);<br />
<br />
SetTextColor(hdc, RGB(ForeColour));<br />
SetBkMode(hdc, BackgroundMode.TRANSPARENT);<br />
TextOut(hdc, x, y, s, System.Text.Encoding.Default.GetByteCount(s));<br />
SelectObject(hdc, fntOld);<br />
DeleteObject(fntNew);<br />
g.ReleaseHdc(hdc);<br />
}
The logfont produced (using the default forms font) is:
LOGFONT
lfHeight: -11
lfWidth: 0
lfEscapement: 0
lfOrientation: 0
lfWeight: FW_NORMAL
lfItalic: 0
lfUnderline: 0
lfStrikeOut: 0
lfCharSet: SHIFTJIS_CHARSET
lfOutPrecision: OUT_DEFAULT_PRECIS
lfClipPrecision: CLIP_DEFAULT_PRECIS
lfQuality: DEFAULT_QUALITY
lfPitchAndFamily: FF_DONTCARE
lfFaceName: Microsoft Sans Serif
I noticed the height was negative and all examples I've seen set it to a positive value, so I tried setting it to 11 before calling CreateFontIndirect and that caused it to not draw at all.
The LOGFONT object and CreateFontIndirect function I used are:
[DllImport("gdi32")]<br />
internal static extern IntPtr CreateFontIndirect([In, MarshalAs(UnmanagedType.LPStruct)] ref LOGFONT lplf);<br />
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]<br />
internal class LOGFONT {<br />
public int lfHeight;<br />
public int lfWidth;<br />
public int lfEscapement;<br />
public int lfOrientation;<br />
public FontWeight lfWeight;<br />
public byte lfItalic;<br />
public byte lfUnderline;<br />
public byte lfStrikeOut;<br />
public FontCharSet lfCharSet;<br />
public FontPrecision lfOutPrecision;<br />
public FontClipPrecision lfClipPrecision;<br />
public FontQuality lfQuality;<br />
public FontPitchAndFamily lfPitchAndFamily;<br />
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]<br />
public string lfFaceName;<br />
}
Any help or ideas on what I'm doing wrong would be great!
|
|
|
|
|
Hi
i want to add User interface Wizard in my application
How it is possible
Please tell the sipmlest solution
Parshant
|
|
|
|
|
There are no wizard controls built into the System.Windows.Forms UI toolkit, however, there are several free ones, such as this one[^], available for download.
|
|
|
|
|
Can anyone help me to add an image in crystal report? I write in C#. In my access database, I store the path of the image , not the real image. The real image is in another directory.
Thank you very much.
|
|
|
|
|
|
See here[^] and here[^]maybe it is some helpful to you
|
|
|
|
|
My application uses a 3rd party component to do serial comms. As part of the initialisation routines of this component it generates an exception.
If I am debugging then this exception takes ages to be caught. The release version takes no time at all.
Why does the first exception take so long, and is there anything I can do about it?
|
|
|
|
|
I would run this by the Visual Studio team in the MSDN forums. Most likely it is due to some COM-related issue, possibly attempting to be caught by a managed debugging assistant. Have you tried turning off MDAs temporarily to see if that affects it at all?
|
|
|
|
|
Hi, it's me again
I have function in an unmanaged DLL declared this way:
unsigned int CWB_ENTRY someFunc();
The CWB_ENTRY is expanded as _System (in a #define preprocessor directive). Anybody knows what calling convention is this?
Thank you.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
I am hoping to write a c# program to log which applications have been started and which ones become active/in focus. I assume I will need some api of somesort or is there something in the .net framework I can use.
Please help
thanks in advance
cjp
|
|
|
|
|
Well, you could periodically poll the System.Diagnostics.Process.GetCurrentProcess() list to see which apps are started. As far determining the active window, there is nothing in the .NET framework to return that information. You'll need to P/Invoke into a Win32 API to obtain this information.
|
|
|
|
|
Hi
a m new in c#
there are some methods of vc++.i want to know what we call in c#
memcpy()
memset()
memcmp();
just i want to copy,compare a block of byte from one buffer to another
and set buffer to null;
and How we can create link list pointer
Parshant
-- modified at 10:30 Thursday 14th September, 2006
|
|
|
|
|
You basically cannot do memory management in C#, so those methods don't have any equivalent in .NET.
What are you trying to achieve?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
You can copy a block of bytes to another byte array using the System.Buffer class[^].
Of course, you can still use pointers and allocate blocks of memory in C#. But typically this is not required, and generally frowned on since it's usually a better practice to let the CLR manage the memory allocations and deallocations for you.
|
|
|
|
|
Anybody has a link to an article where I can find all the possible mappings between C# and C types in order to correctly declare them using DllImportAttribute?
I am looking for types like pointer types, often used to return data to the caller.
Thanks all.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
Hi to all,
I am facing really strange problem. Could you please help me out from that?
LET me describe my requirement.
-------------------------------------------------------------------------------
We have list of "projects" which has some role like - PM, PL, TL, Developer, Tester etc. and absence of any of the person for the particular role, i have to assign other person, which has same role, in the project.
ie database is like this,
PM PL DEV TESTER
Project1 pml pl1 dev1,dev2 t1
Project2 pm9 pl10 dev18,dve20 t3,t10 etc..
PM = pm1,pm5,pm10,pm12 ect..
PL = pl1,pl11,pl10 etc...
so after setting back up of all projects, i have "save" button which save all the projects‘ back up in one table.
-------------------------------------------------------------------------
let's move on GUI...
I have one dropdownList - ddl which has roles (PM,PL,TL etc..)
and in datagrid i have 3 cols
1) Label - project name
2) TextBox - Person who is currently assign the role listed in dropdownList - ddl
3) ListBox - All the person who has same role in database listed in dropdownList - ddl
ie if i select TL in dropdownList, Datagrid shows,
1) all projects 2) person assign TL for the project. 3) all the person who are TL
I have a SAVE button which save all the projects backup at once.
------------------------------------------------------------------------------
To bind the Datagrid, i have use..
**************
asp:Label Runat=server id =name Text='%# DataBinder.Eval(Container,"DataItem.Name")%'
asp:TextBox text= '%# DataBinder.Eval(Container.DataItem,"Asigned Role") %'
Note - this two control bind by DataSet which returns “Project Name” and “Person Name”
***************
asp:ListBox Runat=server id ="ddl1" DataSource='%# getallData1() %' DataTextField="AllRoles" DataValueField="AllRoles" SelectionMode=Multiple
this is i dynamically bind with function "getallData1" which retunrs DataTable with one column - All person who is TL.
---------------------------------------------------------------------------
On save button i wrote code like
***********************************
private void Button1_Click(object sender, System.EventArgs e)
{
ArrayList arr = new ArrayList();
foreach (DataGridItem dgi in DataGrid1.Items)
{
Label lb = (Label) (dgi.Cells[0].Controls[1]);
TextBox tb = (TextBox) (dgi.Cells[2].Controls[1]);
ListBox lb1 = (ListBox) (dgi.Cells[1].Controls[1]); arr.Add(lb.Text.ToString());
arr.Add(tb.Text);
for (int i=0;i < lb1.Items.Count;i++)
{
if (lb1.Items[i].Selected==true) arr.Add(lb1.SelectedItem.Text);
}
}
ListBox1.DataSource = arr;
ListBox1.DataBind();
}
-------------------------------------------------
Right now i want to list all items in LISTBOX1 which has FirstRow as Project NAme, SecondRow TL Name, ThirdRow Backup of TL / BackUp of TLs
---------------------------------------------------
So, main problem is that.. I can access Label – Project Name, TextBox – Person name. But I can’t access the selected Value of Listbox in DataGrid. It always gives me all items as deselected.
Can any one tell me how to get all the records which I selected in Listbox?
Thanks in advance.
Bye.
|
|
|
|
|
I think I understand your problem. To sum all of it up, you want to access the new selected value in the ListBox. I am using a GridView in this code sample but it should work about the same. Instead of using strings with "," you could add straight into your array. Tell me how it works
protected void btnRun_Click(object sender, EventArgs e)
{
int intRowCount = GridView1.Rows.Count - 1;
string strDDLVals = "";
string strLBVals = "";
for (int i = 0; i < intRowCount; i++)
{
strDDLVals += ((DropDownList)GridView1.Rows[i].FindControl ("ddl1")).SelectedValue + ",";
strLBVals += ((ListBox)GridView1.Rows[i].FindControl("ListBox1")).SelectedValue + ",";
}
strLBVals.TrimEnd(',');
strDDLVals.TrimEnd(',');
}
|
|
|
|
|
It's working.....
Thank you very much
|
|
|
|
|
Hi to all,
I am facing really strange problem. Could you please help me out from that?
LET me describe my requirement.
-------------------------------------------------------------------------------
We have list of "projects" which has some role like - PM, PL, TL, Developer, Tester etc. and absence of any of the person for the particular role, i have to assign other person, which has same role, in the project.
ie database is like this,
PM PL DEV TESTER
Project1 pml pl1 dev1,dev2 t1
Project2 pm9 pl10 dev18,dve20 t3,t10 etc..
PM = pm1,pm5,pm10,pm12 ect..
PL = pl1,pl11,pl10 etc...
so after setting back up of all projects, i have "save" button which save all the projects‘ back up in one table.
-------------------------------------------------------------------------
let's move on GUI...
I have one dropdownList - ddl which has roles (PM,PL,TL etc..)
and in datagrid i have 3 cols
1) Label - project name
2) TextBox - Person who is currently assign the role listed in dropdownList - ddl
3) ListBox - All the person who has same role in database listed in dropdownList - ddl
ie if i select TL in dropdownList, Datagrid shows,
1) all projects 2) person assign TL for the project. 3) all the person who are TL
I have a SAVE button which save all the projects backup at once.
------------------------------------------------------------------------------
To bind the Datagrid, i have use..
**************
<asp:label runat="server" id="name" text="<%# DataBinder.Eval(Container,"DataItem.Name")%>">
<asp:textbox text="<%# DataBinder.Eval(Container.DataItem,"Asigned Role") %>" id="AssignRole" runat="server">
Note - this two control bind by DataSet which returns “Project Name” and “Person Name”
***************
<asp:listbox runat="server" id="ddl1" datasource="<%# getallData1() %>" datatextfield="AllRoles" datavaluefield="AllRoles" selectionmode="Multiple">
this is i dynamically bind with function "getallData1" which retunrs DataTable with one column - All person who is TL.
---------------------------------------------------------------------------
On save button i wrote code like
***********************************
private void Button1_Click(object sender, System.EventArgs e)
{
ArrayList arr = new ArrayList();
foreach (DataGridItem dgi in DataGrid1.Items)
{
Label lb = (Label) (dgi.Cells[0].Controls[1]);
TextBox tb = (TextBox) (dgi.Cells[2].Controls[1]);
ListBox lb1 = (ListBox) (dgi.Cells[1].Controls[1]); arr.Add(lb.Text.ToString());
arr.Add(tb.Text);
for (int i=0;i < lb1.Items.Count;i++)
{
if (lb1.Items[i].Selected==true) arr.Add(lb1.SelectedItem.Text);
}
}
ListBox1.DataSource = arr;
ListBox1.DataBind();
}
-------------------------------------------------
Right now i want to list all items in LISTBOX1 which has FirstRow as Project NAme, SecondRow TL Name, ThirdRow Backup of TL / BackUp of TLs
---------------------------------------------------
So, main problem is that.. I can access Label – Project Name, TextBox – Person name. But I can’t access the selected Value of Listbox in DataGrid. It always gives me all items as deselected.
Can any one tell me how to get all the records which I selected in Listbox?
Thanks in advance.
Bye.
|
|
|
|
|
Hi all,
Has any one integrated MSN Messenger with their chat applications?
IF yes how do i do that?
Any links or pointers in this context will be appreciated.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|