|
You really should write an internal wrapper class that encapsulates the unmanaged resource. This class should have the responsibility for acquiring and releasing the resource properly and safely.
If you are using .NET 2.0, have a look at the SafeHandle[^] class, which may save you a lot of work and hassle.
Also, you need to make sure you implement IDisposable[^] on your wrapper (or the main class if you don't use the wrapper method). Check out http://www.codeproject.com/useritems/idisposable.asp[^] for more details on implementing the Dispose pattern.
|
|
|
|
|
ok i am using .Net 1.1, Suppose i have not used any exception handler and also not implemented the idisposable interface then how the memory will manage.Will this be the memory leakage or unmanage object managed by CLR(if any possible way is there)?
Rickey
|
|
|
|
|
public void Append(bool IsRemote, string name, string message)
{
try
{
// listBox1.Font = new Font("Arial", 10, FontStyle.Bold);
listView3.Font = new Font("Arial",10,FontStyle.Bold);
listView3.ForeColor = Color.Blue;
// listBox1.ForeColor = Color.Red;
}
else
{
listView3.ForeColor = Color.Blue;
//listBox1.ForeColor = Color.Blue;
}
listView3.Items.Add(name + " : " +message);
//listBox1.Items.Add(name + " :" + message);
}
In windows mobile application, how to append the text in listbox or listview?
I tried listbox and listview but both exception coming:
NotSupportedException coming
which one i want to use? Anybody help me
|
|
|
|
|
You could use somthing like this.
ListItem item = new ListItem(message,name);
listBox1.Items.Add(item);
|
|
|
|
|
Thanks,
I tried the code, but listBox1.Items.Add(item) here NotSupportedException coming.
I am testing pocketpc 5.0 emulator using visualstudio2005.
That one listbox/listview can supported or not?.
listbox.selecteditem also not coming.
please help me,
Thanks&Regards
|
|
|
|
|
Hi all,
I am a newbie in C#. Can you suggest me one or two books to start learning C#? I have fair knowledge of C++ and MFC. Also please suggest me some good articles which explains the basics of C# and teaches how to do simple tasks with C#. Thank you very much for your time.
|
|
|
|
|
Just take a look through the beginner articles here. The best way to learn would be to think of a simple application you want to write, start writing it using Google etc to help you. If you become really stuck then post a question here.
I find you always learn more by hands-on-experience
As of how to accomplish this, have you ever tried Google?
|
|
|
|
|
Hi,
I have a datagrid that is binded to a datatable (in form of a dataview). I have a requirement that when a particular column in the grid has a value (say 'stat'), then the entire row should be painted in red(the text should be red) else black.
I have extended DatagridColumnStyles for my custom columns. In the paint method, i check for the value in the dataview and accordingly set the forebrush.However, when the user sorts the grid, although it shows the dataview to be sorted, still, the value retrieved is incorrect. I use the row parameter of paint to get the value from the dataview.
Here is the sample code
protected override void Paint(Graphics g, Rectangle rect, CurrencyManager cm, int row, Brush backBrush, Brush foreBrush, bool rightAlign)
{
bool isStatRow = false;
DataRowView rView = null;
try
{
DataView dview = DataGridTableStyle.DataGrid.DataSource as DataView;
if( dview != null )
{
string strStat = dview.Table.Rows[row]["ORD_SCHEDULE_INTERVAL"] as string;
if( strStat != null )
{
string val = strStat.Trim().ToLower();
if( val.IndexOf("stat") == -1 )
isStatRow = false;
else
isStatRow=true;
}
}
}
catch(Exception ex)
{
}
g.FillRectangle(backBrush, rect);
string str = HelperClass.GetString(GetColumnValueAtRow(cm, row), NullText);
if( isStatRow )
{
g.DrawString(str, DataGridTableStyle.DataGrid.Font, new SolidBrush(Color.Red), rect);
}
else
{
g.DrawString(str, DataGridTableStyle.DataGrid.Font, foreBrush, rect);
}
}
The code works when the grid is first painted, but once the same is sorted, this returns me errorneous values and thus paints the color wrongly. I tried using currencymanager.Current also but to no use.
Any ideas???
Please respond
Ashish Sood
|
|
|
|
|
Hello,
I have the SID of a user and the SID of a group. Now I need to check if the user is member of that group... So I think I should get the members and there SID of a group and then check with a for-loop if the SID is present. Is there anyone that knows how I could do that?
|
|
|
|
|
private void btnRemove_Click(object sender, EventArgs e)
{
ListViewItem item = listView1.SelectedItems[0];
if (item != null)
{
string fileid = item.Tag.ToString();
mcaller.removeShare(fileid);
}
btnRemove.Enabled = false;
}
that one i tried in windows application. successfull
But, now i am doing windows mobile application, the listview.SelectedItems
option not in.Any alternate option??
please give me the solution.
In windows mobile how to create columns in listview?
Anybody help me...
|
|
|
|
|
Hello
Sri harini wrote: Any alternate option??
Yes! Use SelectedIndices instead.
Sri harini wrote: In windows mobile how to create columns in listview?
Same as you would in PC:
MyListView.Columns.Add("MyNewColumn");
NB.
There is an icon in MSDN at the left of each member of a class in the "all members" page, indecating that it's available in .Net compact framework or not. It resembles a PDA. Use those only.
Regards
|
|
|
|
|
Hi, Thanks for your reply.
I tried that one.
ListViewItem item = listView1.SelectedIndices[0];
But error coming:
Cannot implicitly convert type 'string' to 'System.Windows.Forms.ListViewItem'
please help me...
Bi
|
|
|
|
|
Hello
Sure you can't do that. SelectedIndices is a collection of integers. You use them this way:
ListViewItem MyItem;
foreach(int X in MylistView.SelectedIndices)
{
MyItem = MyListView.Items[X];
}
Or more simply if you want to access a certain item -provided that you are sure that there are atleast one selected item-:
ListViewItem MyItem = MyListView.Items[MyListView.SelectedIndices[0]];
If there are no selected items, or you put a number larger than the number of selected items you will get an out of bound error. OTOH I guess you already know that!!
Regards
|
|
|
|
|
Hi Thanks a lot.
Now ok.
But still i want to append the text in listview.
listView3.SelectedIndices = new Font("Arial", 10, FontStyle.Bold);
listView3.Items.Add(name + " : " +message);
listBox1.Items.Add("\n");
That one tried, but still notSupportedException coming..
please give your advise
Thanks&Regards
|
|
|
|
|
Hello
What I understand from your post is that you want to append some text at the end of each selected item in the listView.
First, let's we go through your code:
Sri harini wrote: listView3.SelectedIndices = new Font("Arial", 10, FontStyle.Bold);
Here you are assigning a font object to a collection of integers!! Not appropriate.
Sri harini wrote: listView3.Items.Add(name + " : " +message);
Assuming that message is a string, you are trying to add a string to a collection of ListViewItems! Again same problem
The last line is same as the second. So, your problem lies in not matching your types. You must know which type to use. Usually I keep my MSDN as long as I'm programming. It helps a lot
Now to do the same thing, I suggest this code:
foreach(int Index in listView3.SelectedIndices)
listView3.Items[Index].Text += ": " + message;
You can't change the font of items because it's not supported in compact framework -BTW: I revised MSDN for that;P-
I don't understand why would you add a newline to the end of your item's text?? But if you insist just uncomment the code I commented -after removing the semicolon of course-
Regards
|
|
|
|
|
Hai,
I am trying to add the .cs files to my project in the solution explorer using vs 2005 add-in. But i am not able to do so. Is there any way to do this. Can any one tell me how to create this add-in
Thank You in advance
Phanindra
-- modified at 2:51 Monday 28th August, 2006
Phanindra...
|
|
|
|
|
Hello
Phanindra Kumar wrote: I am trying to add the .cs files to my project in the solution explorer using vs 2005 add-in.
I don't think I got you right!! Are you trying to add a cs file to your project as a new Add-in project??
The way I know it is:
Solution Explorer => Right Click on Project's name => Add => Existing item
Regards
|
|
|
|
|
Hi!
Need your ideas urgently! I have a metafile which I wish to convert to PDF on the fly. The idea is to create a metafile template with placeholder text, which will be parsed and replaced by user information at runtime before generating the PDF. When editing the metafile, I have progressed to the following steps:
1. Called the Graphics.EnumerateMetaFile() method, which calls the callback method (lets call it ‘Play’)
2. Called the callback method and obtain the record data
public bool Play(EmfPlusRecordType recordType, int flags, int datasize, IntPtr data, PlayRecordCallback callback)
{
byte[] dataArray = null;
if (data != IntPtr.Zero)
{
dataArray = new byte[datasize];
Marshal.Copy(data, dataArray, 0, datasize);
}
3. Checked whether the record pertains to writing text on the wmf as follows:
if (recordType == EmfPlusRecordType.DrawString)
4. Called the Metafile.PlayRecord() method to draw the new metafile.
mf.PlayRecord(recordType, flags, datasize, dataArray);
What I’m unable to do is, to parse the dataarray (which contains record data), such that I can replace existing text with new text.
Thanks a LOT for any insights.
Regards,
Kunaal
|
|
|
|
|
Sir, I want to My Projects run any Computer default size.I try more but not a success.Please help me.Please Code provide me.
|
|
|
|
|
Could you elaborate on that?
I understand that you want to set the size of something, but I have no idea if you are talking about window size, font size, or whatever.
---
b { font-weight: normal; }
|
|
|
|
|
Hello
First of all welcome to CP.
Second, two things -among other things- are considered very rude here
1- Reposting your same question in the same forum within a short period even if you didn't get an answer on your previous post.
2- Cross posting questions in inappropriate forums.
So, please delete your previous message, and keep this one.
Now, to your issue. Please post the code that's troubling you, or in your case, more details about the size problem.
Regards
|
|
|
|
|
Sir, I want to My Projects run any Computer default size.I try more but not a success
|
|
|
|
|
What are you trying to say??
Please explain in detail.
Every is Illusion
|
|
|
|
|
The maskedTextBox control has the mask property, which set the default format of the text of this control. when the user haven't inputed any text in it, the text property of the control isn't "", the text of it is determined by the mask property of maskedTextBox control, and in my programm the mask property of the control is dynamic and changed by the condition. I need to judge if the user haven't input anything in this control. How can I do it?
mario dai
|
|
|
|
|
Hello
Try comparing the Text property with the Mask property
Regards
|
|
|
|