Jump to content
Xtreme .Net Talk

rickarde

Members
  • Posts

    14
  • Joined

  • Last visited

Personal Information

  • .NET Preferred Language
    VB.NET

rickarde's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi! This piece of code (from my extended datagrid class implem.) if((this.DataSource).GetType() is DataSet){ ... } can't compile, saying that The given expression is never of the provided ('System.Data.DataSet') type ??? Why, since the datasource property of a datagrid returns an Object which can be either a DataTable, a DataSet etc. I want to, at runtime, determine whether the datasource is a DataTable or a DataSet... /Rickard
  2. Of course, this would be a smooth solution, but... I have to make it the hard & "cheap" way... Anyone ? /Rickard
  3. Hi! I wonder how I can get my inherited datagrid to behave like other controls when tabbing around my winform ? As it is, per default, the tab key, once the datagrid has got focus, moves focus around inside the datagrid, along the columns and rows. This is what I want the arrow keys to do, while the tab key should "enter" or "leave" the datagrid... Overriding the isInputKey method is not enough since it, correctly leaves it to me to handle the key events for the tab key, but also makes the selected row unselected... /Rickard
  4. Hi! Having a datagrid wherefrom I, initially, remove the HScrollBar, I can't get the area where the bar was placed to act properly. The portion of my screen that is right behind this area shows through. Looks like the control's not redrawing itself. This works perfect when switching the parent Tab Page to another and then back - redrawing is done. But when I start the app and for the first time enters this tab page, the problem occurs. I have tried to invalidate the entire datagrid, the rectangle corresponding to the HScrollBar (before it was removed) and then updating, but nothing happens. This is my code: ... Dim rect As Rectangle Dim h_scroll As New HScrollBar Dim ctrlList As New ArrayList For Each ctrl As Control In myGrid.Controls If TypeOf ctrl Is HScrollBar Then rect = New Rectangle(CType(ctrl, HScrollBar).Location, CType(ctrl, HScrollBar).Size) edgAerendetyper.Controls.Remove(ctrl) End If Next edgAerendetyper.Invalidate(rect) ' Tried with invalidate(True) also edgAerendetyper.Update() ... This code is executed just after setting the data source... Any suggestions what's wrong ? /Rickard
  5. But if you don't want the text wrapped to next line? I want the part of the text that don't fit in the rectangle/cell (in datagrid) to vanish... Then I can show the full text at OnMouseOver event! /Rickard
  6. Hi! I have a question about the drawString method of a Graphic object. The SDK doc says "...If the text does not fit inside the rectangle, it is truncated." But this don't seem to work for me. I'm implementing this method in an overloaded version of the Paint method in an inherited class of the DataGridTextBoxColumn class. In my datagrid the text, when it fills up more than the width of the cell (rectangle), is "multilined", in other words - it's placed in two rows. The code I use in the paint method is as follows:' Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean) Dim rect As New RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height) Dim sf As New StringFormat sf.LineAlignment = StringAlignment.Center sf.Alignment = StringAlignment.Near Dim e As DataGridFormatCellEventArgs e = New DataGridFormatCellEventArgs(rowNum, Me._col, Me.DataGridTableStyle.DataGrid.Font, backBrush, foreBrush) RaiseEvent SetCellFormat(Me, e) If e.UseBaseClassDrawing Then MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight) Else g.FillRectangle(e.BackBrush, bounds) g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString, e.TextFont, e.ForeBrush, rect, sf) End If If (e.TextFont Is Me.DataGridTableStyle.DataGrid.Font) = False Then e.TextFont.Dispose() End If End Sub Could the problem depend upon the StringFormatter that's used ? Can anyone tell me how to get the text truncated instead of having it in extend the no of lines ? One solution could be to measure the pixels of the text and then truncate it, when needed, and use an invisible data grid column containing the full text. I need the full text value since I'm showing a tool tip when hovering the mouse over the cell. But I was hoping for a smother solution... /Rickard
  7. Hi! I'm removing the horizontal scrollbar from a datagrid - looping through the controls of the grid - and then updates/refreshes the grid, but there is still a problem with the area where the scrollbar would hav been placed - it gets transparent showing parts of what's behind my Windows form. Probably, the grid isn't "repainted" but I really don't know how to make it work. Tried invalidating-updating/refreshing, but... I'm not really a pro in this, so.. someone... /Rickard
  8. Problem solved Found it. It was not int the form load the datasource was set, but in the SelectedIndexChanged, and since the TabControl initialization is prior to the TableStyle initialization and the TabControl initialization includes setting the SelectedIndex to 0 (= fires the SelectedIndexChanged => datasource is set) there will be a default tablestyle already created when the "designerassigned" tablestyle is to be initialized and attached to the datagrid... Solution: Don't set the datasource until the form is loaded and the designer assigned tablestyle is initialized...
  9. Hi! What if I placed a datagrid on a win form, then in the form_load event assign a datatable as datasource, ran the app, stopped the app, and then, in the designer added a new tablestyle with the same mapping name as the table name. Now running he app, I should get the data from the datatable presented in the grid with my tablestyle assigned through the designer, and not with the default tablestyle - which will be assigned to a datagrid that has no tablestyles assigned at design time. Im testing a third part component "EasyDataGrid" which makes life easier when wanting to put images, links and other non standard stuff into a datagrid cell, but the problem is that I can't get it to cope with my design time added tablestyle after having ran the app once before. It complains that there is already a tablestyle with the same mappingname assigned to the datagrid. WHY??? /Rickard
  10. Ho! I have a problem with my datagrid. Clicking in a cell gives me an error. But this error only occurs if I click on a different row than current: "A first chance exception of type 'System.Exception' occurred in system.windows.forms.dll Additional information: CurrentCell cannot be set at this time. Moving your code to FormLoad should solve this problem." I believe it must occur somewhere in the currentCellChange event handler but what can possibly be the problem ? I've been modifiyng the datagrid and how it's "designed"(tablestyle, datagridtextboxcolumns ...) and I'm adding them at run time. This is a part of the code that adds the DG-Tablestyle & DG-TextBoxColumn . . myGrid.TableStyles.Add(newTS()) . . myGrid.dataSource = someDataTable . . Private Function newTS() As DataGridTableStyle Dim tblStyle As New DataGridTableStyle(False) Dim dgtbc As New DataGridTextBoxColumn Dim altColor As System.Drawing.Color = Color.FromArgb(240, 239, 244) ' TABLESTYLE INITIERING tblStyle.MappingName = "ofLog" tblStyle.ReadOnly = True tblStyle.ColumnHeadersVisible = True tblStyle.AlternatingBackColor = altColor tblStyle.RowHeadersVisible = False ' DATE: dgtbc = New DataGridTextBoxColumn dgtbc.MappingName = "Datum" dgtbc.ReadOnly = True dgtbc.Width = 110 dgtbc.NullText = "" dgtbc.HeaderText = "Datum" dgtbc.Format = "yyyy-MM-dd" dgtbc.TextBox.BackColor = Color.Red tblStyle.GridColumnStyles.Add(dgtbc) ' STATUS: dgtbc = New DataGridTextBoxColumn dgtbc.MappingName = "Status" dgtbc.ReadOnly = True dgtbc.Width = 150 dgtbc.NullText = "" dgtbc.HeaderText = "Status" tblStyle.GridColumnStyles.Add(dgtbc) ' VALIDERING: dgtbc = New DataGridTextBoxColumn dgtbc.MappingName = "antal_fel" dgtbc.ReadOnly = True dgtbc.Width = 75 dgtbc.NullText = "" dgtbc.HeaderText = "Validering" tblStyle.GridColumnStyles.Add(dgtbc) ' NYA GRUPPER: dgtbc = New DataGridTextBoxColumn dgtbc.MappingName = "nya_grupper" dgtbc.ReadOnly = True dgtbc.Width = 75 dgtbc.NullText = "" dgtbc.HeaderText = "Nya Grupper" tblStyle.GridColumnStyles.Add(dgtbc) ' NYA ÄRENDETYPER: dgtbc = New DataGridTextBoxColumn dgtbc.MappingName = "nya_aetyper" dgtbc.ReadOnly = True dgtbc.Width = 100 dgtbc.NullText = "" dgtbc.HeaderText = "Nya ärendetyper" tblStyle.GridColumnStyles.Add(dgtbc) Return tblStyle End Function /Rickard
  11. Thanx for your reply but... I've played with this for a while and one thing I've come up to is to remove all editable controls in the datagrid (not the scrollbars though) and this makes the entire row selected (since I only use grid to show data, not to enter data). But my task right now is to make the grid work like a standard window list - e.g. MS Outlook "message list"... This means I have to handle control/shift click, using arrows (with shift/controol also) and combinations of them... /Rickard
  12. Hi! I'm wondering in which order things occur when: - clicking different rows in a datagrid - moving the "selected" row in a datagrid I guess it's something like this: keyDown/mouseDown currentCellChanged keyUp/mouseUp The thing is, I'm actually curious to find out exactly where a row gets selected, not having implemented any extended features in the scenario. I'm into creating a datagrid which rows gets fully selected, and not just the text in the text boxes. I'm almost there, and the answer to this question will make me through... /Rickard
  13. OK, this works for a mouse click, but what if you wnat the same behaviour with the user using the arrow keys. It works holding the shift key but not with simple arrow key navigation... /Rickard
  14. Hi! I have a problem driving me *%/#&"% crazy. Using VS.NET 2003 (CR integrated), Win 2000 Server, IIS, I'm just developing a simple web app testing the possibility to export web forms to pdf - through CR. WebForm1 gathers simple data from user, the user makes, through a click, a submit to reportView.aspx where, in page_load sub, the following code lies: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim xmlStr As String xmlStr = "<persons xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='C:\inetpub\wwwroot\pdfWebCreator\personXSD.xsd'>" xmlStr += "<person>" xmlStr += "<firstname>" xmlStr += Session.Item("firstName") xmlStr += "</firstName>" xmlStr += "<secondname>" xmlStr += Session.Item("secondname") xmlStr += "</secondname>" xmlStr += "<phonenr>" xmlStr += Session.Item("phonenr") xmlStr += "</phonenr>" xmlStr += "<personid>" xmlStr += Session.Item("personid") xmlStr += "</personid>" xmlStr += "</person>" xmlStr += "</persons>" If Session.Item("xmlStr") Is Nothing Then Session.Add("xmlStr", xmlStr) Else Session.Item("xmlStr") = xmlStr End If If IO.File.Exists("c:\inetpub\wwwroot\pdfwebcreator\webPerson.xml") = False Then Dim sw As IO.StreamWriter = IO.File.CreateText("c:\inetpub\wwwroot\pdfwebcreator\webPerson.xml") sw.WriteLine(xmlStr) sw.Flush() sw.Close() sw = Nothing Else IO.File.Delete("c:\inetpub\wwwroot\pdfwebcreator\webPerson.xml") Dim sw As IO.StreamWriter = IO.File.CreateText("c:\inetpub\wwwroot\pdfwebcreator\webPerson.xml") sw.WriteLine(xmlStr) sw.Flush() sw.Close() End If Dim Fname As String = "c:\inetpub\wwwroot\pdfwebcreator\test.pdf" ' dsPerson is a dataset created at design time dsPerson.ReadXmlSchema("c:\inetpub\wwwroot\pdfwebcreator\personXSD.xsd") dsPerson.ReadXml("c:\inetpub\wwwroot\pdfwebcreator\webPerson.xml") Dim rptPerson As person rptPerson = New person rptPerson.SetDataSource(dsPerson) crvPerson.ReportSource = rptPerson crvPerson.DataBind() rptPerson.ExportOptions.ExportDestinationType = CrystalDecisions.[shared].ExportDestinationType.DiskFile rptPerson.ExportOptions.ExportFormatType = CrystalDecisions.[shared].ExportFormatType.PortableDocFormat rptPerson.ExportToDisk(CrystalDecisions.[shared].ExportFormatType.PortableDocFormat, "c:\inetpub\wwwroot\pdfwebcreator\test2.pdf") Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.WriteFile(Fname) Response.Flush() Response.Close() System.IO.File.Delete(Fname); End Sub But, though I've played around with several posibilities in code I still end up with the same error: Stack Trace: [LogOnException: Logon failed.] �.�F(String � , EngineExceptionErrorID � ) �.�A(Int16 ��, Int32 ��) �.�@(Int16 ��) CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext) CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext) CrystalDecisions.Web.ReportAgent.u(Boolean �N) CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) System.Web.UI.Control.PreRenderRecursiveInternal() System.Web.UI.Control.PreRenderRecursiveInternal() System.Web.UI.Control.PreRenderRecursiveInternal() System.Web.UI.Page.ProcessRequestMain() Where in my code should I even have to do a logon, using an XML file, an XSD schema. I even tried, suggested somewhere else, to set userid in the viewer - LogonInfo..... - to "Admin" but nothing seems to work. Please help a desperate man /Rickard
×
×
  • Create New...