Click here to Skip to main content
15,902,918 members
Home / Discussions / C#
   

C#

 
GeneralRe: JIT debugger Error. Pin
Sunil G19-Jan-10 1:11
Sunil G19-Jan-10 1:11 
GeneralRe: JIT debugger Error. Pin
OriginalGriff19-Jan-10 1:16
mveOriginalGriff19-Jan-10 1:16 
GeneralRe: JIT debugger Error. Pin
Luc Pattyn19-Jan-10 1:14
sitebuilderLuc Pattyn19-Jan-10 1:14 
GeneralRe: JIT debugger Error. Pin
OriginalGriff19-Jan-10 1:19
mveOriginalGriff19-Jan-10 1:19 
GeneralRe: JIT debugger Error. Pin
Sunil G19-Jan-10 1:25
Sunil G19-Jan-10 1:25 
QuestionContextMenuStrip dynamic item widths Pin
DarrenShultz18-Jan-10 18:42
DarrenShultz18-Jan-10 18:42 
AnswerRe: ContextMenuStrip dynamic item widths Pin
April Fans19-Jan-10 17:52
April Fans19-Jan-10 17:52 
GeneralRe: ContextMenuStrip dynamic item widths Pin
DarrenShultz19-Jan-10 19:08
DarrenShultz19-Jan-10 19:08 
Yes, I had tried that. However, it did not accomplish what I wanted to achieve. The menu item will be completely custom drawn, but there is some text that I'll need to assure will fit. So, I calculated the width of a space in the menu item font, measured that text that will be rendered to it (though text measuring in .NET is sometimes inaccurate), and set the menu item text to all spaces (see code below). However, every menu item in that drop down will have the same height now if there is more than one line. And, we have no way of making the menu item an exact dimension since we can only affect width/height using spaces and newlines in the menu item text. Ideally, I'd like to know if there is a clean way to resolve such drop-down menu and menu item dimension inconsistencies. Perhaps a "DoWhatIWant" flag? Smile | :)

private void AutoSizeCustomMenuItem(ToolStripMenuItem oMenuItem, string sText)
{
  int iPreferredHeight = 50;
  int iPreferredWidth = 0;
  int iPadding = 50;
  SizeF oSizeSpace = SizeF.Empty;

  using (Graphics oGraphics = oMenuItem.Owner.CreateGraphics())
  {
    iPreferredWidth = (int)oGraphics.MeasureString(sText, oMenuItem.Font).Width + iPadding;
    oSizeSpace = oGraphics.MeasureString(" ", oMenuItem.Font);
  }

  int iSpacesWidth = (int)Math.Ceiling((double)(iPreferredWidth / oSizeSpace.Width));
  int iSpacesHeight = (int)Math.Ceiling((double)(iPreferredHeight / oSizeSpace.Height));
  string sSpacesWidth = new String(' ', iSpacesWidth);

  StringBuilder sbMenuItemText = new StringBuilder();
  if (iSpacesHeight > 0)
  {
    string sLineDivider = String.Empty;
    for (int i = 0; i < iSpacesHeight; i++)
    {
      sbMenuItemText.Append(sLineDivider);
      sbMenuItemText.Append(sSpacesWidth);
      sLineDivider = "\r\n";
    }
  }
  oMenuItem.Text = sbMenuItemText.ToString();
}

Questionexport DataGridView to excel 2007 in c# Pin
H.R18-Jan-10 18:21
H.R18-Jan-10 18:21 
AnswerRe: export DataGridView to excel 2007 in c# Pin
dan!sh 18-Jan-10 19:17
professional dan!sh 18-Jan-10 19:17 
QuestionKeep from erasing working code in a project Pin
tonyonlinux18-Jan-10 18:11
tonyonlinux18-Jan-10 18:11 
AnswerMessage Closed Pin
18-Jan-10 18:46
stancrm18-Jan-10 18:46 
GeneralRe: Keep from erasing working code in a project Pin
tonyonlinux18-Jan-10 20:29
tonyonlinux18-Jan-10 20:29 
GeneralRe: Keep from erasing working code in a project Pin
Bekjong18-Jan-10 22:02
Bekjong18-Jan-10 22:02 
AnswerRe: Keep from erasing working code in a project Pin
Ashfield18-Jan-10 21:09
Ashfield18-Jan-10 21:09 
Questionexport .m file from text file in VS2008 Pin
mohamadali&M18-Jan-10 18:10
mohamadali&M18-Jan-10 18:10 
AnswerRe: export .m file from text file in VS2008 Pin
Ashfield18-Jan-10 21:13
Ashfield18-Jan-10 21:13 
QuestionKeyEventArgs - differentiate control chars on numeric keypad [modified] Pin
cdesmarais18-Jan-10 12:21
cdesmarais18-Jan-10 12:21 
AnswerRe: KeyEventArgs - differentiate control chars on numeric keypad Pin
Luc Pattyn18-Jan-10 16:07
sitebuilderLuc Pattyn18-Jan-10 16:07 
Questionmanaged and unmanaged code............ Pin
3bood.ghzawi18-Jan-10 10:12
3bood.ghzawi18-Jan-10 10:12 
AnswerRe: managed and unmanaged code............ Pin
Not Active18-Jan-10 11:42
mentorNot Active18-Jan-10 11:42 
QuestionHow to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
GeniusMchlahla18-Jan-10 7:34
GeniusMchlahla18-Jan-10 7:34 
AnswerRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
J. Dunlap18-Jan-10 13:11
J. Dunlap18-Jan-10 13:11 
GeneralRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
GeniusMchlahla19-Jan-10 5:23
GeniusMchlahla19-Jan-10 5:23 
GeneralRe: How to Select Drawn Objects Without Getting a System.Windows.Forms.Control Pin
J. Dunlap19-Jan-10 6:27
J. Dunlap19-Jan-10 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.