|
The obvious solution is a webbrowsercontrol, as that already knows how to show PDFs, and can be added to a form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I'm thinking how to do a text wrap calculation for a string by myself. I need to calculate how many lines will a string wrapped to (within a fixed area region). The fixed region is a location and an area for filling the string. I also have to know which part of the string is wrapped to the corresponding line. Could some of you give me some ideas?
e.g.
string txt1 = "AbcdefgHigklmnopqrstuvWxyz. Dear, Hello Hello My Friend...";
if the fill region is limited to the size of "100x400",
what is the good way to calculate how many lines will the txt1 wrapped to?
as we can imagine, txt1 maybe wrapped into 3 lines.
1st line: AbcdefgHigklmnopqrs
2nd line: tuvWxyz. Dear, Hello
3rd line: Hello My Friend...
I'm thinking to use graphics.MeasureString to calculate the width of each character. is it a good way..
I would be appreciated if you can give me some example?
Thanks so much for your help?
|
|
|
|
|
MeasureString can be used on the whole string, keep cutting until it fits. Make a string of what's left and start again.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Could anyone show me some examples?
I feeling difficult how to initial the Graphics, so that it measure the String in correct unit,
|
|
|
|
|
Hey folks,
I have to write some C# code to call passport-authenticated web services to verify if some user has the privilege to do that.
This is the first time that I work with passport authentication.
Could anybody please shed some light where I should start or if possible, some sample code that I should follow?
Any help is appreciated.
Thanks,
Johny
|
|
|
|
|
I need to have a DataGridView column that has cells that are exactly like the DataGridViewTextBoxCell cells, except:
1. There is a list of characters (such as '*' and '&') that will be invalid. If the user types them, the cell should ignore the keystroke.
2. There can be a maximum of 8 characters in the text field at one time.
3. All lower case characters will automatically be displayed as upper case characters.
I was hoping I could do this all by just overwriting some method, but it looks like I have to make my own custom control that extends TextBox (as well as my own custom cell type to handle the custom control and then a custom column type to handle the custom cell). And that will require me to implement so many methods and properties.
Am I missing an easy way that someone else knows about?
|
|
|
|
|
I did something similar, instead of wrting a new column type, just create a custom textbox, make it a control in your grid and whenever the user clicks the cell you place this box in place of the clicked cell. When the user leaves the textbox, make it invisible again and copy the valueto the cell. Works great and not too much code to write
|
|
|
|
|
Hi, I have an MS Access table and I wish to get information into a DataSet or DataTable using a SQL query. This is my code:
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"DataSource=C:\Program Files\Wiki\WikiProject.mdb";
string commandString = "SELECT All_Data.* FROM All_Data WHERE ((All_Data.City)=New_York)";
OleDbConnection con = new OleDbConnection(connectionString);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, con);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "All_Data");
The error I get is "Could not find installable ISAM". How can I solve this error? or - Is there another way to get a specific line from a MS Access table?
Thanks,
Yoni
|
|
|
|
|
|
hi
i want to begin Client/Server Database Programming with c#2005 and sql 2000 or 2005,but i don't found any sorce code or article that show me how to use sql transactions in database.
does anybody know how to do this or take me link,Source or Guidance ?
thanks.
|
|
|
|
|
|
The following code works well, when I tab trought the emptyDataGrid the cells are in edit mode but when the form shows up, the emptyDataGrid seems to be focused because if I tab I fall in the second cell of the grid but if I just type it doesn't put the keystrokes in the first cell, it is like the first cell is not in edit mode. Tried multiple things but nothing works. Not sure what to do.
The result that should be obtained is as soon as the form shows up, at the first keystroke the first cell of emptyDataGrid should be in edit mode and registering keystrokes of course.
Thanks for any help. (Writing a good finder is definitely the worst thing I never tackled in programming)
public void SetFinder(ref ComplexObject finderObject)
{
finderObject.Read();
complexObject = finderObject;
dataGrid = finderObject.FinderDatagrid;
dataGrid.ColumnHeadersVisible = false;
datagridSplit.Panel2.Controls.Add(dataGrid);
foreach (DataColumn column in finderObject.Tables[0].Columns)
{
if (column.ColumnMapping == MappingType.Element)
{
emptyTable.Columns.Add(new DataColumn(column.ColumnName, column.DataType));
}
}
emptyTable.Rows.Add(emptyTable.NewRow());
emptyTable.AcceptChanges();
emptyDataGrid.DataSource = emptyTable;
emptyDataGrid.AllowUserToAddRows = false;
emptyDataGrid.AllowUserToResizeRows = false;
emptyDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
emptyDataGrid.Dock = DockStyle.Fill;
emptyDataGrid.RowHeadersVisible = false;
emptyDataGrid.ScrollBars = ScrollBars.None;
datagridSplit.Panel1.Controls.Add(emptyDataGrid);
datagridSplit.SplitterDistance = emptyDataGrid.PreferredSize.Height + 5;
emptyDataGrid.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(emptyDataGrid_EditingControlShowing);
emptyDataGrid.CellLeave += new DataGridViewCellEventHandler(emptyDataGrid_CellLeave);
emptyDataGrid.CellEnter += new DataGridViewCellEventHandler(emptyDataGrid_CellEnter);
dataGrid.Scroll += new ScrollEventHandler(dataGrid_Scroll);
emptyDataGrid.Scroll += new ScrollEventHandler(emptyDataGrid_Scroll);
emptyDataGrid.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(emptyDataGrid_ColumnHeaderMouseClick);
}
void emptyDataGrid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (emptyDataGrid.SortOrder == SortOrder.Ascending) { dataGrid.Sort(dataGrid.Columns[emptyDataGrid.SortedColumn.Name], ListSortDirection.Ascending); }
else { dataGrid.Sort(dataGrid.Columns[emptyDataGrid.SortedColumn.Name], ListSortDirection.Descending); }
}
void emptyDataGrid_CellEnter(object sender, DataGridViewCellEventArgs e)
{
emptyDataGrid.BeginEdit(true);
}
|
|
|
|
|
Hi everyone
how would i add text to a rich text box named 'richTextBox1' located in Form1 with the namespace "winApp1"...
i am adding text from a function inside a different class like this:
winApp1.Form1.richTextBox1.Text
but all i get is:
'winApp1.Form1.richTextBox1' is inaccessible due to its protection level
how can i remove the protection
Thanks in advanced
Roman
|
|
|
|
|
Declare richTextBox1 as public or internal.
|
|
|
|
|
thanks, why didn't i think of that
|
|
|
|
|
Hello good people,
I recently discovered the GCHandle class and its use.
However, I can't seem to understand something...
In one of my projects I'm using SetWindowsHookEx() , which gets a function pointer, or a delegate to be exact...
However, I've no use with this delegate whatsoever...
My first attemt at writing the code was something like the following:
SetWindowsHookEx(... ,new BlaBlaDelegate(MyCallback), ...); The above, sometimes, generated an exception which said that I tried to reference a null object (Not in these exact words of course ).
The solution I came up with was to keep a reference in a global variable inside my class.
So the new code is somewhat like:
BlaBlaDelegate bla;
...
SetWindowsHookEx(..., bla = new BlaBlaDelegate(MyCallback), ...); Works fine.
As MSDN documents:
"...Once allocated, you can use a GCHandle to prevent the managed object from being collected by the garbage collector when an unmanaged client holds the only reference. Without such a handle, the object can be collected by the garbage collector before completing its work on behalf of the unmanaged client."
Question is... Should I use GCHandle instead of holding a direct reference?
If so, when should I use the Free() method?
Right after the call to SetWindowsHookEx() ?
GCHandle is supposed to "prevent the managed object from being collected...when the unmanaged client holds the only reference.".
So why use the Free() method right after the API call? (That's what MSDN examples show BTW)
Thanks in advance,
Shy.
|
|
|
|
|
In this case, the delegate to your MyCallback needs to stay alive for as long as you want the hook to work. So, if your windows hook lasts for as long as your application is running, never call Free() on the object.
Why the MSDN example calls free right away, I've no idea. Are they using GCHandle for keeping an object alive just for a single call (i.e. no callbacks)?
|
|
|
|
|
|
I'd just use a direct reference, but whatever works I guess.
Really odd...seems like the MSDN article is wrong. Either I'm missing something or the article is wrong.
|
|
|
|
|
I need to create an intranet website (stored within a company firewall) where a customer can call our support desk and the system checks which reps are currently available to answer a phone call, then routes the phone call to the rep via VOIP.
In other words, each rep will not be speaking through a phone but rather their PC (which I'm assumming only VOIP can handle).
I'd prefer to create my own .NET app to handle this so if anyone knows of a tutorial or a good starting point to begin researching, that would be great. Also, if anyone knows of a commercial solution already out there that can handle this, I'd appreciate that info as well.
Thanks in advance.
-Goalie35
|
|
|
|
|
No, I don't mean hiding it under a box or something.
I need a way, from a console app, to completely hide the mouse cursor. Back in the days of Window 3.1, I think I did something like that once. You think I still have the code for that? HAHAHA!
So, how do you do it?
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Cursor.Hide
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: Cursor.Hide
That doesn't work for a console app.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
namespace HideMouse
{
class Program
{
static void Main(string[] args)
{
while (true) {
Cursor.Position = new Point (-10, -10);
}
}
}
} This doesn't hide the mouse, but renders it effectively useless.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: but renders it effectivly useless.
I tried that. The mouse doesn't actually move beyond (0, 0), so there's still a piece of it visible. Possibly because I'm using UltraMon and/or Synergy. I need a system-wide way of doing this.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|